unity AddForce 到 Player onTriggerEnter

时间:2021-02-08 14:59:49

标签: c# unity3d

Screenshot Game"我正在制作一个游戏,我想创建一个当玩家跳到一个盒子上并弹跳时的弹跳脚本 起来,这是我目前所拥有的”

public Rigidbody rb;
public float bounceForce = 3f;

// Start is called before the first frame update
void Start()
{
    rb = GetComponent<Rigidbody>();
    
}

void OnTriggerEnter(Collider coll) {
    if(coll.gameObject.tag == "Player"){
        Debug.Log("Jumpforce");
        GetComponent<Rigidbody>().AddForce (0,bounceForce,0);
        
    }
    
}

1 个答案:

答案 0 :(得分:0)

我知道了

openDialog(): void {
 const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
   width: '250px',
   data: {
     name: this.name, 
     animal: this.animal,
     requestForm: this.requestForm
   }
});
相关问题