How can I get my first-person character in Unity to move to a ledge with an animation?

Posted by BallzOfSteel on Game Development See other posts from Game Development or by BallzOfSteel
Published on 2011-04-12T10:25:38Z Indexed on 2011/11/21 18:11 UTC
Read the original article Hit count: 213

Filed under:
|
|

I'm trying to get this to happen: The character walks up to a large crate, the player presses a button, and an animation starts playing where the character climbs up on to the crate. (all in first person view).

So far I tried this with normal "First Person Controller" Prefab in Unity.

My code so far:

function OnTriggerStay(other : Collider){
    if(other.tag == "GrabZone"){
        if(Input.GetKeyDown("e")){
            animation.Play("JumpToLedge");
        }
    }
}
However when i use this on The FPC it will always play from the position the animation is created on.

I also tried to create an empty game object, placing the FPC in there. Gives same effect.

I also tried just animating the graphics of the FPC alone. This seems to work but since the Character Controller itself is not animated that stays onthe ground. So the whole FPC wont work anymore.

Is there anyway i could let this animation play on the local position the player is on at that time?

Or can you think of any other logical solution for a grab and climb?

© Game Development or respective owner

Related posts about animation

Related posts about unity