#triggering animations
1 messages · Page 1 of 1 (latest)
making a thread here
so, let's look at your code
It looks like this detects when your collider overlaps with the player.
so, if you put this onto a pressure plate, it would run when the player bumps into the pressure plate's trigger collider
It then sets a flag on its own animator (not on the player's)
Did we ever actually get the inspector of the object that this is colliding with
no, but I'd like to make sure I understand what the intent is here
it sounds like this component got moved
done that first , and said collided with "collider", and changed the code for it to the car , now it says collided with "cube"
simple animation when player enters trigger
You can't randomly move stuff around until your game works. You need a clear picture.
Play an animation on what when it enters a trigger on what
An animaton on who? The player? An object?
an animation on an UI text
Okay, so you want to make some text change when the player walks into a trigger zone.
The PlayMyAnimation component should be attached to the same object as your trigger collider, then.
thaat is the animation
(and it should not be attached to the player)
yes , that is what i did first
redoing it now
this is the game btw , the car is the player , the cube is the trigger
Once you do that, check what object is getting logged.
car inside: log-Entered trigger with: Collider
car outs: log-Exited trigger with: Collider
Okay, you need to find the object
here's a shortcut, though
Debug.Log("Entered triggered with: " + collider.gameObject.name, collider.gameObject);
The second argument to Debug.Log is the "context"
it can be any unity object
When you click on the log entry, you'll be taken to the context object
Don't use the word collider for a variable name Unity thinks that's an old depracated field.
then how
oh, it was named other, wasn't it?
Use other, then
your code looks like
void OnTriggerEnter(Collider other) {
}
I was thinking of
void OnTriggerEnter(Collider collider) {
}
Use whatever name you gave the parameter (other, in your case)
By using the actual variable you are currently using
In the ancient past, there were properties like collider and light and rigidbody that existed by default. They're long gone now, but Unity still tries to upgrade them into GetComponent calls.
That's why you got that message.
So, this object is colliding with something named "Cube Collider". Show the updated code, and show the inspector of "Cube Collider"
When you select it, it should highlight that object in the hierarchy for you
wrong code but found the original "collider" , it was in the car body collider
have you come up with something ,sorry for wasting your time btw
I'm still waiting for you to show the inspector of the object you hit
ok
bro this is it
this is the thing that is hitting the car
Okay, so now that matches the message, but you've cropped out the tag you're looking for
Does this object have the tag you are looking for
not cube collider i said the code was wrong , my bad for that but the only thing that is hitting is the car
1 sec
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO SHIT
IT WAS THAT SIMPLE
3 HOURS I JUST NEEDED TO CHECK THE THING WITH PLAYER
BRO I DON'T KNOW HOW TO THANK YOU
Yes that is why I said in my very first message to you that you should check what object you're colliding with and see if it has the tag "Player"
idk bro i'm new
i don't have a clue what i'm doing
i know , i'm just dumb
hard for me to understand that when i don't know the terms
THANK YOU SOO MUCH
i have other problems tho but they are more complicated
✅ Series Playlist: https://www.youtube.com/playlist?list=PLzDRvYVwl53t6iznGWrD_QB66ZoIz2BHa
Grab the Project files and Utilities at https://unitycodemonkey.com/video.php?v=dHzeHh-3bp4
Let's create a UI Arrow Pointer that will point to a location in our world.
If you have any questions post them in the comments and I'll do my best to answer them...
this but in 3d