I've been trying to create a game where once you hit the 'repeat' symbol you have to return to the position of the first repeat symbol ie
once the player hits the "end-repeat sign" they'll return to the "begin-repeat sign" but only once then they'll continue the level, but for some reason the game won't register the symbols even when a rigidbody is added
void OnCollisionEnter(Collision collision){
if(state != State.alive || collisionsDisabled){ return; }
switch(collision.gameObject.tag){
case "Win":
print("win");
StartSucessSequence();
break;
case "Lose":
StartDeathSequence();
break;
case "StartRepeat":
print("touched");
OnTriggerEnter(other);
break;
default:
StartDeathSequence();
break;
}
}
void OnTriggerEnter(Collider other){
// if startrepeat is touched go to endrepeat
//for only once
StartRepeat = GameObject.FindWithTag("StartRepeat");
EndRepeat = GameObject.FindWithTag("EndRepeat");
for (int i = 0; i < 1; i++){
if(other.gameObject.tag == "StartRepeat") {
other.transform.position = EndRepeat.transform.position;
other.transform.rotation = EndRepeat.transform.rotation;
}
}
}
my "Lose" tag is working perfectly, but not my "Win" or "StartRepeat"
I was thinking perhaps it's an issue with the Z-axis cause everything else is similar to the obstacle ("Lose" - which is the red notes)
if anything else is needed please tell me
首先,如果您想使用 2d 刚体,请将您的 OnCollision 和 OnTrigger 更改为 2d ,那么我建议您不要自己调用 OnTrigger 并创建另一个包含 OnTrigger 代码的方法并使用它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.