How can I make a climbing animation / action (wall climbing)?

Hi,

Im beginning to make a new game, where animations are going to play a large part, but havent really experimented too much with mecanim before.

How do I make a climbing animation, that actually moves the player upwards. So if the player faces a wall, and hits shift / space or some button, how would I make it climb up that wall. Also is it possible to make it detect where the wall is and adjust the hand positions according to this?

Any help would be greatly appreciated.

Thanks,

IEMatrixGuy

Hi,

I have no experience with mecanim but i do know a bit about animation. For this your character will need to have any necessary joints rigged in order to make them hinge and you will need a script to activate the animation once in contact with the ladder or wall.

 function OnCollisionEnter(theCollision : Collision){
     if(theCollision.gameObject.name == "Wall"){
      Animation.Play ("Climb");
     }
    }
// This is assuming the animation is called 'Climb'  and the wall is called 'Wall' - Both without the quotation marks.

This script will play the animation once you come in contact with the wall, to make the option to climb only after collision with the wall is out of reach of my coding capabilities (I’m only 13 and an amateur at coding).

I can only help if you would like to use the animator in unity because thats all I know how to use but obviously you want to use mecanim so I’ll let somebody else advise you on that.

I hope this will help and I’m sorry I can’t help with mecanim. I hope your game is successful and good luck!

This will ask one of your question this here will make sure the character is facing the wall he is climbing in C# just a few changes you have to do if you want it in javascript

RaycastHit hit //Declare this somewhere

//RayCast for climbing tags
//Vector3(0,1f,0) adding this to transform.position allows you to adjust the raycast line on your character
//transform.TransformDirection(Vector3.forward) Make sure the raycast is turning with the character's direction

//This can be placed in update

		if (Physics.Raycast (transform.position+new Vector3(0,1f,0), transform.TransformDirection(Vector3.forward), out hit)) {

			//Only Climb within certain distance and Climb Tag
			//hit.distance < 0.5f is the distance the Raycast Line is hitting from the character
			// Raising 0.5f to 1 will result in longer distance but 0.5 is usually a good distance for climbing since the character has to touch the wall
			
			if (hit.distance < 0.5f && hit.collider.tag == "Climb") {
				
				//This here will make sure the character is facing the wall he is climbing
				//reason why its -hit.normal because the normal/Polygon is facing towards you and 
				//you want the player to face at the wall instead of mimicking its rotation so you flip it
				
				transform.rotation = Quaternion.LookRotation (-hit.normal);	//This line can be place elsewhere just in case you want to do this only once
			}
			
		}