Advertisement
gotoheavenbro

ThrowFood.cs

Nov 20th, 2014
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ThrowFood : MonoBehaviour {
  5.     public GameObject food;
  6.     public GameObject foodholder;
  7.     public float ThrowSpeed;
  8.     private GameObject _myGameObject;
  9.  
  10.     // Use this for initialization
  11.     void Start () {
  12.         _myGameObject = gameObject;
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.         if (Input.GetMouseButtonDown(0))
  18.         {
  19.             GameObject tempFood=Instantiate(food,_myGameObject.transform.position,_myGameObject.transform.rotation) as GameObject;
  20.             foodholder.GetComponent<FoodHolder>()._foodList.Add(_myGameObject);
  21.             tempFood.rigidbody.velocity = _myGameObject.transform.TransformDirection(Vector3.forward * ThrowSpeed);
  22.         }
  23.        
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement