Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class ThrowFood : MonoBehaviour {
- public GameObject food;
- public GameObject foodholder;
- public float ThrowSpeed;
- private GameObject _myGameObject;
- // Use this for initialization
- void Start () {
- _myGameObject = gameObject;
- foodholder = GameObject.Find("Food Holder");
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetMouseButtonDown(0))
- {
- GameObject tempFood=Instantiate(food,_myGameObject.transform.position,_myGameObject.transform.rotation) as GameObject;
- foodholder.GetComponent<FoodHolder>()._foodList.Add(tempFood);
- tempFood.rigidbody.velocity = _myGameObject.transform.TransformDirection(Vector3.forward * ThrowSpeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement