really new to unity and scripting here.
Basically I created a triggered animation, which I’d hoped would act like an elevator for the First Person Controller.
The elevator lifts through the player.
I’ve tried putting different colliders on the player. I’ve tried adding rigid body to the player.
Any feedback or advice would be greatly appreciated.
Thanks so much for the response.
I tried parenting a small cube with the mesh renderer switched off that was checked as a trigger, but when I did, the lift animation wasn’t triggered.
So I had a block called ‘lift’ and another block which was a trigger.
In the Js code I had:
I wasn’t sure whether that meant I needed to tag the lift block or trigger block with a tag called ‘Lift’.
I’ve tried so many combinations. I’d rather the code be in C#. I’m a real newb, and I’m just trying to get results in the 6-8 hours I have to work it out.
But I will definitely keep trying when I have free time again.
It’s hard to guess the details of your collision from only the scene views, so maybe more details would help.
One thing you should know is that marking a Collider as “Trigger” will have it ignore collisions with the world environment. So I take it your elevator is a “Trigger” and probably won’t collide with anything.
If that’s the case, I’d suggest ticking off the “Trigger” checkbox on the Elevator collider and adding another collider on top of the Elevator that activates the activation when you enter that one instead
Give that a shot, if you need more explanation, more details or if you have further questions or details for us, fire away, otherwise, please accept this answer
The player needs:
- a collider (not too small), not trigger
- a rigidbody
For the elevator, you can have two different colliders : 1 trigger and 1 not triggered. As ThePersister said, triggered ignore physics collisions.
An other way is to create an other gameObject with a trigger, at the same location than the elevator.
The advantage is that when you go back to the elevator, it won’t move up again and again.
Unity animation do not use physics calculations the just move the object