Advertisement
therealnemis

12/18

Dec 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Create Cube Object
  2. Rename to Player
  3. Components - Physics - Rigid Body
  4.  
  5.  
  6. Press play, object will fall down
  7. Create 3D Object, Plane
  8.  
  9. Scale to 10 x 10
  10.  
  11. Create C# script called player
  12. Attach to player object
  13.  
  14. public class Player: MonoBehaviour {
  15. public float speed = 6;
  16. RigidBody myRigidBody;
  17. Vector3 velocity;
  18. void Start(){
  19. myRigidbody = GetComponent<RigidBody> ();
  20. }
  21.  
  22. void Update(){
  23. Vector3 input = new Vector3 (Input.getAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
  24. Vector3 direction = input.normalized;
  25. velocity = direction * speed;
  26. }
  27.  
  28. void FixedUpdate(){
  29. myRigidBody.position += velocity * Time.fixedDeltaTime;
  30. }
  31. }
  32.  
  33.  
  34. Create more cube objects, with different materials so that you can differentiate the colors
  35. Apply to platform, and cubes
  36. Press green y axis
  37.  
  38. Create obstacles, change the scaling
  39.  
  40. press play
  41.  
  42. 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