Thursday, February 2, 2017

Day 3

Today I worked on the movement of the player sphere.

This was my first introduction to programming in C# and it seems pretty neat :D

I started off by making a script and adding the script to the player.

Then I opened up the script in Microsoft Visual Studio and started working on it.

I made a variable called "rb" and made it get the value of "RigidBody" (rigidbody defines that the object will interact with the physics and gravity and all.)


Then I made 2 variables "moveHorizontal" and "moveVertical" and gave them each the value of "Input.GetAxis ("Horziontal" and "Vertical")


What this does is it stores the input that you give it in the variable.

After this I finally worked on adding a force that actually moves the sphere.

I used a function called "Vector3" which is pretty much stores the x,y,z coordinates and i made moveHorizontal the x axis, gave 0 to y axis (because we don't wanna move up), and moveVertical to Z axis.

Then I added a force to rigid body using the code ".AddForce".


So I tested the game and the ball was a bit too slow moving so I had to fix this,

I made a public variable called "speed" and then I multiplied my movement by speed 

And now i can change the speed in the inspector without actually having to open the code.
Like this:




This is how the game looks so far


Tomorrow I will be continuing the tutorial :D

No comments:

Post a Comment