#triggering animations

1 messages · Page 1 of 1 (latest)

cold karma
#

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)

glass venture
#

Did we ever actually get the inspector of the object that this is colliding with

cold karma
#

no, but I'd like to make sure I understand what the intent is here

#

it sounds like this component got moved

lavish obsidian
#

done that first , and said collided with "collider", and changed the code for it to the car , now it says collided with "cube"

cold karma
#

No, don't tell me what stuff you've done.

#

Tell me what you want this to do

lavish obsidian
#

simple animation when player enters trigger

cold karma
#

You can't randomly move stuff around until your game works. You need a clear picture.

glass venture
cold karma
#

An animaton on who? The player? An object?

lavish obsidian
#

an animation on an UI text

cold karma
#

Okay, so you want to make some text change when the player walks into a trigger zone.

lavish obsidian
#

yes

#

from transparent to visible

cold karma
# cold karma

The PlayMyAnimation component should be attached to the same object as your trigger collider, then.

lavish obsidian
#

thaat is the animation

cold karma
#

(and it should not be attached to the player)

lavish obsidian
#

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

cold karma
#

Once you do that, check what object is getting logged.

lavish obsidian
#

car inside: log-Entered trigger with: Collider
car outs: log-Exited trigger with: Collider

cold karma
#

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

lavish obsidian
glass venture
# lavish obsidian

Don't use the word collider for a variable name Unity thinks that's an old depracated field.

cold karma
#

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)

glass venture
cold karma
#

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.

lavish obsidian
#

and i updated, did i do something wrong?

#

btw this is the message

glass venture
#

When you select it, it should highlight that object in the hierarchy for you

lavish obsidian
#

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

glass venture
lavish obsidian
#

ok

lavish obsidian
#

this is the thing that is hitting the car

glass venture
lavish obsidian
glass venture
# lavish obsidian

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

lavish obsidian
#

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

glass venture
#

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"

lavish obsidian
#

idk bro i'm new

glass venture
lavish obsidian
#

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

#

this but in 3d