- Home /
Stop Root Motion if out of boundaries? Simple Wall Climbing System
Hi Unity Community, I have a simple climbing system, in which I use animations with root motion to move the player character up , down, and side to side on a wall. To do this, I use a small script, which will be at the bottom of this post. My problem is that I cannot figure out how to add boundaries to where the player is able to climb. For example, if I have a wall that the player is climbing, and I move the player to the right to the edge of the wall, he is able to keep going to the right even after running out of wall (so the character appears to be floating in mid air). Is there a way to solve this? Am I missing something basic?
Here is my climbing script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class climbManager : MonoBehaviour {
Animator animator;
// Use this for initialization
void Start () {
animator = GetComponent();
} // Update is called once per frame void Update () {
//CLIMB LEFT if(Input.GetKeyDown(KeyCode.A))
{
animator.SetBool("climbLeft", true);
;
}
if(Input.GetKeyUp(KeyCode.A))
{
animator.SetBool("climbLeft", false);
}
//CLIMB RIGHT
if (Input.GetKeyDown(KeyCode.D))
{
animator.SetBool("climbRight", true);
}
if (Input.GetKeyUp(KeyCode.D))
{
animator.SetBool("climbRight", false);
}
//CLIMB DOWN
if (Input.GetKeyDown(KeyCode.S))
{
animator.SetBool("climbDown", true);
}
if (Input.GetKeyUp(KeyCode.S))
{
animator.SetBool("climbDown", false);
}
//CLIMB UP
if (Input.GetKeyDown(KeyCode.W))
{
animator.SetBool("climbUp", true);
}
if (Input.GetKeyUp(KeyCode.W))
{
animator.SetBool("climbUp", false);
}
}
}
Answer by Mwester · Dec 06, 2017 at 04:18 PM
Bump. Still can't seem to figure this thing out. Any suggestions?
Your answer
Follow this Question
Related Questions
How to trigger different animations depending on where a gameobject collides? 1 Answer
Using OnControllerColliderHit and Instantiate to pick up objects but... 2 Answers
How do I create two colliding Spheres? 1 Answer
How can I have a CharacterController's height make it to where the feet are correctly on the ground? 0 Answers
Collision - 2 Objects 1 Answer