hello guys…
i m working on game and i have a problem…i want that my character will follow a path and i can switch that path with arrow key anytime in the game and most important my character behave like a rigidbody…how can i do this …plz help me…
If you are moving along the x axis (forward from your characters point of view), then all you need to do is adjust the Z axis. This might be the long way to do it, but it wil work never the less.
var currentPath : int;
var distBetweenPaths : float = 10.0f; // distance between each path, assuming that all paths have equal distances
function Start()
{
currentPath = 2 // if you have 3 paths, then number 2 will be the middle one. Set your player on this path to begin with
}
function Update()
{
if(Input.GetKeyDown(KeyCode.S) currentPath > 1) // currentPath is either 2 or 3
{
transform.position.z -= distBetweenPaths;
currentPath--;
}
if(Input.GetKeyDown(KeyCode.W) currentPath < 3) // currentPath is either 1 or 2
{
transform.position.z += distBetweenPaths;
currentPath++;
}
}
hmmm,yes i want this…but how i can get this …
Then you would probably use game objects and send the player to each object. Assuming this path will be permanent. I’m not familiar with pathfinding though so I’m not 100% sure if thats the right way to go.
EDIT: I will try and figure out a solution when I get home and share it with you.
actully i did this with theta algorithm(pathfinder) and my character were following that path but it didn`t behave like a rigidbody …and i want that is my character behave like a rigidbody …

