私は消防士のようなゲームに取り組んでいます、ここではプレイヤーが布で火を消さなければならないシナリオです。私は布を作りましたが、いつでもそれを選ぶことができます私はそれを投げる、それは投げていない、それはそこに残った。 ここで私は布を(特定の距離で)火に投げたい。ここまで私がこれまで行ったコードです。どんな提案、どこに問題がありますか?または何をすべきか?特定の距離でアイテムを投げる
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);
}
}
}