Boomerang Problem
Roksalt
Member Posts: 87
So I have boomerang using the following rules:
game.touch x
game.touch y
Rule
when touch is pressed
change attribute game.touch x to touch position x
change attribute game.touch y to touch position y
Player shoots the object
The object then interpolates its X and Y positions to those game attributes.
then once it gets to those attributes, it returns back to the players X and Y.
Works great...
The problem however is that it takes the same amount of time to get from the player to the destination every time... this looks funny if its only being thrown a short distance (say 50 px from the player) as opposed to the entire screen (300px).
Basically whats the formula for "Duration" that will allow it to adjust its speed depending on how far it has to travel so that its faster for short throws / slower for long throws.
(BTW I have tried a "move to" behaviour as well but found it very unreliable as it didn't always return but interpolate works 100% of the time)
Thanks
game.touch x
game.touch y
Rule
when touch is pressed
change attribute game.touch x to touch position x
change attribute game.touch y to touch position y
Player shoots the object
The object then interpolates its X and Y positions to those game attributes.
then once it gets to those attributes, it returns back to the players X and Y.
Works great...
The problem however is that it takes the same amount of time to get from the player to the destination every time... this looks funny if its only being thrown a short distance (say 50 px from the player) as opposed to the entire screen (300px).
Basically whats the formula for "Duration" that will allow it to adjust its speed depending on how far it has to travel so that its faster for short throws / slower for long throws.
(BTW I have tried a "move to" behaviour as well but found it very unreliable as it didn't always return but interpolate works 100% of the time)
Thanks
Comments
Although this works its seems a bit unreliable for my purposes and as soon as many enemies start coming onto the screen it occasionally doesn't return.
I've found that the interpolates work every time so i think i'll just use that method.
Cheers