Skip to main content

Posts

Showing posts with the label unity move player object tutorial

#P6 Kick Start - Unity [Moving the player]

1. Create project folder 2. Name the folder as scripts 3. Create new component, new script, name it as PlayerController, the script name must be started using Capital letter. Drag the script to "scripts" folder. *change the language to c# 4. Lets start scripting! double click the PlayerController script, it ll lead us to MonoDevelop-unity, scripting editor that bundled with unity software. using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { void FixedUpdate () { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); //how much we want our object to move on the y-axis? nono //set to o.of float y_axis = 0.0f; //store the vector object in moving variable; Vector3 movement = new Vector3 (moveHorizontal, y_axis, moveVertical); rigidbody.velocity = movement; } } *ensure the method called Fixed...