Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create Cube Object
- Rename to Player
- Components - Physics - Rigid Body
- Press play, object will fall down
- Create 3D Object, Plane
- Scale to 10 x 10
- Create C# script called player
- Attach to player object
- public class Player: MonoBehaviour {
- public float speed = 6;
- RigidBody myRigidBody;
- Vector3 velocity;
- void Start(){
- myRigidbody = GetComponent<RigidBody> ();
- }
- void Update(){
- Vector3 input = new Vector3 (Input.getAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
- Vector3 direction = input.normalized;
- velocity = direction * speed;
- }
- void FixedUpdate(){
- myRigidBody.position += velocity * Time.fixedDeltaTime;
- }
- }
- Create more cube objects, with different materials so that you can differentiate the colors
- Apply to platform, and cubes
- Press green y axis
- Create obstacles, change the scaling
- press play
- If you want to lock rotation, go to Rigidbody in side menu, Constraints, and check x y and z for rotation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement