View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1lucky6969b  Members

Posted 28 June 2014 - 03:22 PM

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, 28 June 2014 - 03:27 PM.

### #2ApochPiQ  Moderators

Posted 28 June 2014 - 04:28 PM

Are you trying to visit a specific location or all locations? These are very different problems.
Wielder of the Sacred Wands

### #3lucky6969b  Members

Posted 29 June 2014 - 10:58 PM

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

Thanks

Jack

### #4belfegor  Members

Posted 30 June 2014 - 07:35 AM

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, 30 June 2014 - 07:37 AM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.