- Home /
Character getting stuck on curbs..
Hey guys,
My character works very well except when he hits something tiny, he just gets stuck. How can it automatically move up small things like this? Ive tried a box, capsule and mesh collider and nothing seems to be able to do it.
What I'm talking about.. Notice its just his legs. lol..
You guys are lifesavers!! Thanks!
The movement script.. using UnityEngine; using System.Collections;
public class Addbuttons : MonoBehaviour {
void OnGUI()
{
//Forwards
if (GUI.RepeatButton(new Rect(65, Screen.height-125, 70, 30), "Forward") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Translate(transform.forward/20 , Space.World);
}
//Backwards
if (GUI.RepeatButton(new Rect(65, Screen.height-50, 70, 30), "Backward") == true)
{
GameObject Player = GameObject.Find("objPlayer");
//Player.transform.Translate(transform.forward/20 , Space.World);
}
//Left
if (GUI.RepeatButton(new Rect(10, Screen.height-90, 70, 30), "Left") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Rotate(0,-2,0);
}
//Right
if (GUI.RepeatButton(new Rect(120, Screen.height-90, 70, 30), "Right") == true)
{
GameObject Player = GameObject.Find("objPlayer");
Player.transform.Rotate(0,2,0);
}
}
// Update is called once per frame
void Update () {
}
}
This is an unusual way to move a player, you may want to reconsider the design of using OnGUI for this. I'm assu$$anonymous$$g the small things have a collider on them - could you turn those off without changing your game design?
Your answer
Follow this Question
Related Questions
Making a bubble level (not a game but work tool) 1 Answer
Circular movement of the player 0 Answers
How can i smooth out the rotation? 1 Answer
movement 2d in a grid 3 Answers
Player movement isn't working 1 Answer