Change the character's animation on interaction with objects

Dear game developers,:slight_smile:

I am new to unity 3d. im struggling with character animations. my need is, i have a 3d model with multiple animations like walk, run, jump, punch, crouch, pulling a handle(for door) like that. i made those things in 3ds max and exported to Unity as .FBX file. I seperated the animations. i used default third person controller script which is available in Unity. since it has only the functions like walk, idle, run and jump. i need to add “punch” animation when i press “Fire1”.

Another thing is, i have a animation for pulling the doors. it should only to be work when the character is near the door. i.e when the player moved to the door and presses a key (e or something) the animation “pulling door” should be run. if the player is somewhere else other than door, the function should not be work. how can i do this?

Does anyone have ideas. Waiting for ur replies

You can do a ray, or make a trigger area around de door

do u hav any simple scripts for that?

wat i really need is how can i control the character’s animation on clicking other game objects (like door)?..

r u want script for this?

u can onCollisionEnter function will. be best option…!

i would disagree, unless you make the collider of the door way bigger then the size of the door, otherwise i would use raycast, if you use collision then the door wont open until you run head first right into it, and thats not very natural.

paulharisson, just look up physics raycast in the script reference, theres plenty of examples in there… youll want something with a hit data, so you can say if hit.transform == door.transform, open door