Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

How can I make an object follow a fixed path (track)? but...

This topic is 1479 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The vehicle called the VNA will follow a fixed path which is the aisle between the rackings.

But at some point, the VNA will be able to stop at each bay. What is the best way to move this object?

Waypoints, or weighed A* (don't know what that's called), but something like the path within the straight line

will be given the highest score.

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
Are you trying to visit a specific location or all locations? These are very different problems.

Share this post


Link to post
Share on other sites

Yes, I'd like to visit specific locations, it's like a vehicle on rail in a straight line back and forth.

Thanks

Jack

Share this post


Link to post
Share on other sites

I am not sure what is your problem.

If you want to move object to specific location:

1. (opt) rotate it to face target location

2.

targetLocation = Path[currNodeInx].node_pos
objectPos += (targetLocation - objectPos).normalize() * moveSpeed

3. test if reached destination and increment path index:

minimumDist = 0.1 // minimum dist to target to consider it has reached its current destination
minimumDistSq = minimumDist*minimumDist // squared
if((targetLocation - objectPos).lengthSq() < minimumDistSq)
{
    currNodeInx++ // or decrement if you want to go back, or wrap around so it will loop thru the path
   
}

4. you can add something like weight to Path to modify moveSpeed so object will move slower/faster

targetLocation = Path[currNodeInx].node_pos
objectPos += (targetLocation - objectPos).normalize() * moveSpeed * Path[currNodeInx].weight
Edited by belfegor

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!