Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. using System.Collections;
  5.  
  6. public class FunkyBallController : MonoBehaviour
  7. {
  8.  
  9. // Is the player moving
  10. public bool walking;
  11. //How fast can the player move
  12. public float speed;
  13. public GameObject particleEffect;
  14.  
  15. //public Animator anim;
  16. //Get the players rigidbody
  17. private Rigidbody rb;
  18.  
  19. // Use this for initialization
  20. void Start()
  21. {
  22.  
  23.  
  24. //Get and store a reference to the Rigidbody2D component so that we can access it.
  25. rb = GetComponent<Rigidbody>();
  26. // m_Animator = gameObject.GetComponent<Animator>();
  27. walking = false;
  28. // facingRight = true;
  29.  
  30.  
  31. }
  32.  
  33. //FixedUpdate is called at a fixed interval and is independent of frame rate. Put physics code here.
  34. void FixedUpdate()
  35. {
  36. // PlayerHealth PlayerHealth = GetComponent<PlayerHealth>();
  37.  
  38. // if (PlayerHealth.isDead == false)
  39.  
  40. float moveHorizontal = Input.GetAxis("Horizontal");
  41.  
  42. float moveVertical = Input.GetAxis("Vertical");
  43.  
  44. Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
  45.  
  46. rb.AddTorque(Vector3.down * speed * Input.GetAxis("Horizontal") * Time.deltaTime);
  47.  
  48. rb.AddForce(movement * speed * Time.deltaTime);
  49.  
  50.  
  51. }
  52.  
  53. private void OnCollisionEnter(Collision col)
  54. {
  55. if (col.collider.tag.Equals("Wall"))
  56. {
  57. Instantiate(particleEffect, transform.position, particleEffect.transform.rotation);
  58. }
  59. }
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement