0
我正在製作一款遊戲,就像一名消防員,這裏是玩家必須通過布來撲滅火焰的場景,我已經成功製作了一塊布,而且我可以挑選它,但是當我扔它,它不會扔,它仍然存在。 在這裏,我想扔布在火(特定距離)。這是我迄今爲止所做的代碼。任何建議,問題在哪裏?或者該怎麼辦?在特定距離拋出物品
using UnityEngine;
using System.Collections;
public class pickup : MonoBehaviour {
public Transform OnHand;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
if (Input.GetButtonDown ("E")) {
GetComponent<Rigidbody>().useGravity=false;
this.transform.position = OnHand.position;
this.transform.parent = GameObject.Find ("FPSController").transform;
this.transform.parent = GameObject.Find ("FirstPersonCharacter").transform;
}
if (Input.GetMouseButtonDown (0)) {
this.transform.parent = null;
GetComponent<Rigidbody>().useGravity=false;
// Rigidbody.AddForce (new Vector2(1,4), ForceMode.Impulse);
}
}
}