Advertisement
Guest User

ThrowFood.cs

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