Interpolate not based on static time?

ericzingelerericzingeler 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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It would help to know what you're trying to interpolate (e.g. self.position.X) and what effect you want it to have (e.g. speed up when closer to another actor, etc.). I think any sort of manual interpolation is going to require a timer or at the very least a loop (which also requires a timer).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ericzingelerericzingeler Member Posts: 334
    Sorry, should have been more specific. Let's say I want to move an Actor from Point A to Point B. The kicker is, Point B is dynamic (will change). I want to use interpolate, but have the movement based on a set speed instead of duration.

    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?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Perhaps I'm overlooking something, but wouldn't Change Velocity achieve that?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2012
    Perhaps your example isn't saying what you meant. But at any velocity -- it always takes half the time to get to point B2 (50) when point B1 (100) is twice the distance.


    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
Sign In or Register to comment.