Advertisement
crystalguy123

Untitled

Jan 28th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Powerup : MonoBehaviour
  6. {
  7.  
  8.  
  9. private float _speed = 3.0f;
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. // Start is called before the first frame update
  19. void Start()
  20. {
  21.  
  22. }
  23.  
  24. // Update is called once per frame
  25. void Update()
  26. {
  27. //move down at speed of 3 m/s
  28. transform.Translate(Vector3.down * Time.deltaTime * _speed);
  29.  
  30. //when leave screen destroy object
  31. if(transform.position.y == -6.0f)
  32. {
  33. Destroy(this.gameObject);
  34. }
  35.  
  36.  
  37. }
  38.  
  39. //ontriggercollision
  40. //only be collectable by the player (tags)
  41. //on collected, destroy
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement