How to check if player has collided with gameobject.

Hello, I’ve been trying to do this thing for a jam but I don’t know how to fix this.
How do I make it so if the player has collided with a GameObject called PlatformTriggered then play this camera animation. The script in camera, since the animation is a camera animation.
Yeah, it’s probably simple but I can’t think straight right now and I only have 2 days left for a game jam, so if you could help, that’d be great.
Thanks.

Just because your script is going to update the camera doesn’t mean it has to be attached to the camera!

I’d create a script that’s attached to the player object, and in its OnCollisionEnter method, get the GameObject associated with the object collided with. If it’s the object you want, play the camera animation, either using Camera.main or via a reference that you’ve assigned in the Inspector.

Good luck with the jam! Make sure you get some rest!

2 Likes

Thanks for the help! I am a little confused on how to implement it using a reference.

have you used Unity before? do you know about the dragndrop behavior with the game objects and the inspector fields?

1 Like