Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class FunkyBallController : MonoBehaviour
- {
- // Is the player moving
- public bool walking;
- //How fast can the player move
- public float speed;
- public GameObject particleEffect;
- //public Animator anim;
- //Get the players rigidbody
- private Rigidbody rb;
- // Use this for initialization
- void Start()
- {
- //Get and store a reference to the Rigidbody2D component so that we can access it.
- rb = GetComponent<Rigidbody>();
- // m_Animator = gameObject.GetComponent<Animator>();
- walking = false;
- // facingRight = true;
- }
- //FixedUpdate is called at a fixed interval and is independent of frame rate. Put physics code here.
- void FixedUpdate()
- {
- // PlayerHealth PlayerHealth = GetComponent<PlayerHealth>();
- // if (PlayerHealth.isDead == false)
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
- rb.AddTorque(Vector3.down * speed * Input.GetAxis("Horizontal") * Time.deltaTime);
- rb.AddForce(movement * speed * Time.deltaTime);
- }
- private void OnCollisionEnter(Collision col)
- {
- if (col.collider.tag.Equals("Wall"))
- {
- Instantiate(particleEffect, transform.position, particleEffect.transform.rotation);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement