23/11/2018
Today Chris sent us all a task and we all had to follow step by step from the tutorial video to make a cube move using ‘keys’
Email/Tutorial
Dear all,
There’s a good chance your game will involve moving a player or object around, so I want you to see how this is done using C# code.
Watch and follow this video, then show me what you’ve done. Take screenshot (or screen recording) evidence and add to your WordPress.
The tutorial is easy to follow and only lasts about 14 minutes. It shows you the start() and update() functions in use, which are similar to setup() and draw() in processing. It will also remind you about variables and floats.
Deadline – This needs to be done by 1pm.
Challenge – See if you can have a more interesting player (rather than a cube) or more interesting terrain (rather than a plane).
https://www.youtube.com/watch?v=sXQI_0ILEW4&t=24s
Update
So far following the tutorial I’ve created a 3D cube and changed the colours of the cube and the floor, and also added some shadow onto the cube.

After watching more I done a code where the cube will just move on its own, I’ll leave two screen shots below.
Now I’ve got the cube to move from right to left by using the keys ‘A’ and ‘D’ I’ll leave screen shots below, one from the middle, one moved to the right and the other one moved to the left. I’ll also leave the code that I’ve got so far under the pictures so just incase someone is stuck and can help them.
Code
public class cube : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
print (Input.GetAxis(“Horizontal”));
transform.Translate(Input.GetAxis(“Horizontal”)* Time.deltaTime,0f,0f);
}
}
I’ve added into the code so you can use the keys ‘a’ ‘d’ ‘s’ ‘w’ so you can go left and right up and down, in the code I’ve also added movement speed and put it on 5 so when you move the cube it’s faster then it was. I’ll also leave screen shots below and also the updated code.
The code – below and as you can see I’ve made the movement speed ‘5’.

After we had to get rid of everything and get a new floor and a ball, we had to install standard assets package from the store and install it.

We had to get the camera to follow the ball around the map, I found this tutorial on YouTube and it helped me a lot link below.
After following the tutorial my camera now follows the ball around.
Here’s the code for the movement of the ball, Ill post a picture below just incase its easier for anyone to copy.

I had an idea for this 3D practice game to get shapes to stand up and move the ball and knock them over, after watching YouTube tutorials and getting ideas from my 2D game I managed to get the shapes to stand up and when the ball hits them they fall over.
Leave a comment