Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class KinamaticMovement : MonoBehaviour {
- public float movementSpeed = 0.2f;
- private bool isMovement;
- // Use this for initialization
- void Start () {
- isMovement = true;
- }
- // Update is called once per frame
- void Update () {
- if(isMovement == true)
- {
- movement();
- }
- if(isMovement == false)
- {
- }
- }
- void movement()
- {
- transform.Translate(movementSpeed * Time.deltaTime, 0f, 0f );
- }
- void noMovement()
- {
- // Debug.Log("Executed no movement");
- transform.Translate(0f, 0f, 0f);
- }
- void OnTriggerEnter(Collider other)
- {
- // Debug.Log("Collision detected");
- if(other.gameObject.CompareTag("Plate"))
- {
- Destroy(this.gameObject);
- // Debug.Log("object destroyed");
- }
- if(other.gameObject.CompareTag("Ground"))
- {
- // Debug.Log("object collision with ground");
- isMovement = false;
- Destroy(this.gameObject);
- noMovement();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement