"shortestway" when tweening hotspots

  • Dear Klaus, dear community,

    I'm facing the following problem...

    I'm trying to create a game, in which there is a weapon at the bottom of the screen (a plugin), which is then firing various objects as hotspots. I can manage to tween these "bullets" to their target, which is basically the Stage.mouseY and Stage.mouseY coordinates in AS3, but the problem is that for example if the starting ath of the bullet is like 130, and the target is at -165 (which is right across the screen) it will travel out of the screen all the way around the pano sphere and end up at it's target coming in from the other edge of the screen.

    Now if I understand correctly, when using the lookto command there's a similar issue which is solved by using the "shortestway" property with a true value.

    My question is, can anyone give me a tip on how to solve this programmatically? Maybe Klaus you could give me a hint on how you implemented the shortestway feature inside krpano, so that I can code something similar...at this point I'm struggling hard to get an idea on how to accomplish this.

    So in other words, and to sum things up, what I need is to tween any hotspot from a given starting ath to a given ending ath using the shortest way on the screen regardless of the ath atv values. Note that both the starting, and ending ath values are always INSIDE the current screen (calculated using screentoshpere from the weapon and the mouse x,y coordinates).

    Any help would be very welcome! Thanks!

  • Just to note I also tried using plugins for the bullets, but then of course there the problem that if the user rotates the view when firing the bullets move with the screen rotation, so I came to the conclusion that this can only be done using hotspots....

  • Ok, after coutnless tries I came up with a solution, but I think it's not really good performance-wise, so I'm still open for advices.

    What I did is I basically now tween these hotspot bullets using onscreen coordinates from a pseudo object, and then at the beginning of the tween I also store the initial hlookat value, and adjust the ath,atv on the fly according to the changes in it's value.

    This way the hotspots end up exactly at the point the mouse cursor was pointing when the firing of this bullet occured, even if the view rotates during it's motion.

    If anyone has a better idea, or a cleaner method, please be sure to share :) Thanks!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!