Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ladder example

Discussion in 'Scripting' started by ron, Sep 5, 2008.

  1. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    hi all,

    I've extended a ladder example project I found in the forum. I managed to allow the FPS character to climb a ladder.

    Basically I placed a box collider as trigger at the bottom of the ladder and at the top of the ladder. These triggers tell me where I am relative to the ladder. The character can climb onto the ladder (at top or bottom) by pressing y when it touches the trigger. The character can then climb up and down using the up-down-arrows. Is the character at the bottom or top and on the ladder it can climb off the ladder by pressing b.

    The climbing on and climbing off movement is very simplistic. I struggle to change the orientation of the character (turning towards the ladder). Have you got any ideas?

    I've implemented the behaviour in the FPSController script and swaped it with the standard FPSWalker script. Have a look if you're interested. Any comments are very welcome.
     
  2. burnumd

    burnumd

    Joined:
    May 27, 2008
    Posts:
    367
    That's pretty cool! I was doing something similar recently, but I attached the script to the FPS object and just tagged the ladder endpoints so I called SendMessage() on its own GameObject rather than GetComponent() on the object the endpoints collided with. To orient the player towards the platform at the top or bottom, I offset the collision volumes for the endpoints and set the transform of the player to the endpoint's center when it exits the laddder. You just have to be careful that the collision volumes line up so you don't get trapped on the ladder. Also, I might stick in flags to determine whether the player is restricted from climbing up or down (since it's currently possible to climb up from the top of the ladder into space).
     
  3. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    burnumd, thanks for your comments. I like the idea of translating the player to the centre of the collision volumes at start and end point of the ladder.

    do you only translate the character or do you rotate it towards the ladder too? could you just quickly explain how you turn the player towards the ladder? I figured that the MouseMove script overrides any rotations.
     
  4. blutwurstchen

    blutwurstchen

    Joined:
    Jun 11, 2010
    Posts:
    21
    Where is this example you are talking about?
     
  5. Ingen

    Ingen

    Joined:
    Jul 6, 2012
    Posts:
    2
  6. meo109

    meo109

    Joined:
    Dec 25, 2012
    Posts:
    1
    Thanks Ingen this link is very helpfull, yabada badouuuuuuuuu !!!!