Interpolate not based on static time?
ericzingeler
Member Posts: 334
Ok, so I know the interpolate behavior is awesome, but what if you don't want to base the behavior on time. There's gotta be some math I can do to base it on something such as distance or speed. Anyone?
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
For example:
If Point B(1) = 100 and Point B(2) = 50, the time it takes to travel from A to Point B(2) should take half the time as traveling to Point B(1). Make sense?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Edit:
Maybe you want something that will move the position of the actor half the distance to the goal (on each update). Like this:
Constrain Attribute: self.Position.X To: self.Position.X +(( game.Mouse.Position.X - self.Position.X )*.25)
Constrain Attribute: self.Position.Y To: self.Position.Y +(( game.Mouse.Position.Y - self.Position.Y )*.25)
(Actually, this one moves it one quarter of the distance to the goal on each update. You can change the '.25' to match the speed you need.)
Edit #2
If constraining x & y position isn't useful. Here's a formula that uses velocity instead:
Constrain Attribute: self.Motion.Linear Velocity.X To: ((game.Mouse.Position.X-self.Position.X)*.9)*5
Constrain Attribute: self.Motion.Linear Velocity.Y To: ((game.Mouse.Position.Y-self.Position.Y)*.9)*5