Boomerang Problem

RoksaltRoksalt Member Posts: 87
edited April 2013 in Working with GS (Mac)
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

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    There are probably several ways to do this. I'd suggest something like this file:
  • RoksaltRoksalt Member Posts: 87
    Thanks for the suggestion.

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