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

Started by
2 comments, last by belfegor 9 years, 10 months ago

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

Advertisement
Are you trying to visit a specific location or all locations? These are very different problems.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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

Thanks

Jack

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

This topic is closed to new replies.

Advertisement