interpolate drama.. moving an object around on screen by click destination
part12studios
Member Posts: 620
Hi there,
I've been working on a game where i am allowing a vehicle to be positioned from where it is to another location within a radius of the current position.
The core problem i'm having is that it works.. but the weird thing is that when i click the destination the first time it works.. then the 2nd time i do it it doesn't.. but then the 3rd time i do it it does it!
to offer some contrast, doing a direct "change attribute" works perfect each time..
what it feels like is that the interpolate transition needs to reset somehow and i've tried a number of different approaches to this but nothing is working. nothing is working through..
Is there some other better way to move an object around? I've tried things like "move too".. using the x and y of the two interpolates i'm using to create a nice tween like effect..
its just so bizarre how its behaving.. its all working as i like EXCEPT this thing about having to click the action twice each time.. i'm confident as best i can tell that various conditions are resetting correctly.. this is backed up by the fact that "change attribute" replacements work perfect each time.. but that result is unacceptable because the actor jumps to the new location instantly.
Oh yea one other thing.. the interpolate issue doesn't happen IF i don't let the actor come to a complete stop. strange stuff.. if i keep the interpolate in motion.. then it works.
Thanks
Caleb
I've been working on a game where i am allowing a vehicle to be positioned from where it is to another location within a radius of the current position.
The core problem i'm having is that it works.. but the weird thing is that when i click the destination the first time it works.. then the 2nd time i do it it doesn't.. but then the 3rd time i do it it does it!
to offer some contrast, doing a direct "change attribute" works perfect each time..
what it feels like is that the interpolate transition needs to reset somehow and i've tried a number of different approaches to this but nothing is working. nothing is working through..
Is there some other better way to move an object around? I've tried things like "move too".. using the x and y of the two interpolates i'm using to create a nice tween like effect..
its just so bizarre how its behaving.. its all working as i like EXCEPT this thing about having to click the action twice each time.. i'm confident as best i can tell that various conditions are resetting correctly.. this is backed up by the fact that "change attribute" replacements work perfect each time.. but that result is unacceptable because the actor jumps to the new location instantly.
Oh yea one other thing.. the interpolate issue doesn't happen IF i don't let the actor come to a complete stop. strange stuff.. if i keep the interpolate in motion.. then it works.
Thanks
Caleb
Best Answers
-
tatiang Posts: 11,949Can you post your interpolate rules? Interpolate's a bit tricky and it mostly depends on whether you are trying to interpolate an attribute to a variation of itself (e.g. interpolate game.score to game.score+500 won't work).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
RThurman Posts: 2,881@part12studios
You can roll your own interpolations fairly easily. Here are a couple of examples that will give you the ease-out motion you are looking for:
This one is done with velocity:
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
This one is done with positions:
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)
-
tenrdrmer Posts: 9,934Have a read of this old thread. http://forums.gamesalad.com/discussion/21933/interpolation-revelation#latest if I remember when I get home in the morning ill upload 2 projects that should help you learn more about moving around with interpolates. It's tough to really use if your movements can change in an instant but I would gue it is possible.
Answers
Ok let me see if i can break it down clearly.. there is probably a more elegant way to do what i'm wanting too..
https://www.dropbox.com/s/tq1go32byn4akkh/example.png
ok so to explain what i'm trying to do.. the idea is that touching the vehicle actor (the one i want to move).. a radius graphic appears.. the rules above are from within that radius graphic.
Actor receives touch and "game.movement armed" true.. (made true by touching the vehicle in the first place). This stuff is happening inside the radius graphic, which is what keeps the player from only being able to move so far away from where the vehicle currently is.
change attribute - the x position of the "stop here" actor
change attribute - the y position of the "stop here" actor
NOTE: This invisible actor was my way of insuring that the x/y of the mouse stayed put.. i tried just having the tanker move to where i clicked, but the interpolate when listening directly to "mouse postiion x/y" it would track the mouse till the interpolate timer stopped. Again probably a more elegant way to achieve this, but this was the best i could come up with..
Interpolate TankerX to move to X
Interpolate TankerY to move to Y
NOTE: this is the crux of the problem. If i replaced these values with a change attribute it works solid every time, but the problem is that i need the actor to move from point a to point b.. not jump instantly.
Change Attribute - Game Movement False.
Change Attribute - Game movement Modulo to 0
NOTE: these attributes do things like False (makes radius go invisible and prevents incidental touches in the radius area from occurring) and modulo of course insures that the on action touching the vehicle allows it to cycle on/off well.
Thanks!
Caleb
Interpolation is just a way to plot points between two known points. (Just like extrapolation is a way to plot points beyond two known points.)
Perhaps an explanation of one of the equations will help others who read this to see how linear interpolation can work:
Constrain Attribute: self.Position.X To:self.Position.X+((game.Mouse.Position.X - self.Position.X)*.25)
The above constrain is is telling the actor to move its x position one fourth (25%) of the distance between its current position and the mouse. Because its a constrain, it does this on every frame update. It is interpolating one point on every update. However, because its one fourth closer on every update, its distance between itself and the mouse decreases every frame. So the closer it gets to the mouse, the less distance it needs to travel. In effect, it looks like its slowing down as it gets closer to the mouse. (Because it actually is!)
for one thing.. the formula entry space really should be a dynamic field that adjusts to the text field size or simple stretches to fit whatever size the box that contains it so you don't have to mouse over each equation.. one is fine.. but Rules can often have numerous ones side by side making it very tedious to compare..
So yea even though i found a solution and it works for the purpose i need (doing a cooldown to restrict moves), it still felt like there is probably a better / smarter way to dynamically do this without having to use smoke an mirrors (cooldown) to get the desired effect.
Thanks!
Caleb