Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tween object rotation doesn't take the shortest path

Author
Message
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 17th Sep 2020 17:48 Edited at: 17th Sep 2020 18:03
I decided to use tweens to do some object rotations in my game instead of writing the functions myself, but I noticed that the rotation doesn't take the shortest path. For example if the tween is set to start rotation at 350 degrees and end at 10 degrees, instead of rotating in the correct direction by 20 degrees it rotates in the opposite direction by 340 degrees...

Obviously I can write the function myself to make the rotation use the shortest path but then I can't use the built in tween interpolations, which basically means I have to write my own tweening routine..

Couldn't the built in commands be fixed to operate correctly?

Example code to reproduce the situation:

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Sep 2020 18:16 Edited at: 17th Sep 2020 18:28
i need to start playing with tweens but:

SetTweenObjectAngleY(box_tween, -10, 10, 3)

meanwhile, i'm trying to find justification for this behavior. nothing yet.
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 17th Sep 2020 18:52
Sure that works, however I am just using 350 and 10 as an example. In the game the starting angle isn't arbitrary, it's the actual object angle at the given time. The function should simply be written so that the object never rotates more than 180 in one direction. After all if the difference is greater than 180 degrees, then it's smaller than 180 degrees in the opposite direction.. seems intuitive to me and would be fairly easy to accomplish.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Sep 2020 19:15 Edited at: 17th Sep 2020 19:20
i guess what i'm struggling with is Euler Angles. does something in what those are determine which direction? otherwise, we're just using "standard?" angles (while the parameter require Euler)?
sorry if i'm taking this on a tangent. and, i see what you mean about writing your own function to accomplish what you want. i'm just trying to help decide if it's a bug, or normal behavior.
so far, google isn't helping me understand so, i'm trying to understand if THIS explains what we're experiencing.
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 17th Sep 2020 21:33
Quote: "The function should simply be written so that the object never rotates more than 180 in one direction."


What if i want it to do that?
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 18th Sep 2020 01:55
Ok fair enough, so perhaps they could implement a flag parameter to choose either shortest path, clockwise or counterclockwise rotation.

Also I'm sure I can figure out how to apply some math to get the current function to work how I want I just need to think about it for a bit.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th Sep 2020 09:49 Edited at: 18th Sep 2020 09:52
It is performing exactly as I would expect it to.
If I set the tween to rotate from 350 degrees to 10 degrees then I would expect it to rotate 340 degrees anti-clockwise, because that is what it is being asked it do.
If, instead I wanted it to rotate 20 degrees clockwise (as you do) then I would set the tween to rotate from 350 degrees to 370 degrees.

I have removed the [BUG] text from the title because this is definitely NOT a bug!
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 18th Sep 2020 15:54
Sure that's fine, but please understand the point here is that very often we are using the angle delivered by other functions like getobjectangle or a look at dummy, and they don't return values outside of 0-360.. just for example rotating an object to look at the player, a very common requirement.

So like I said I can probably figure out the math needed to game the function into operating like I need but I would think far more people need shortest path functionality than not.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th Sep 2020 18:41 Edited at: 18th Sep 2020 18:41
I would say far more people need the correct functionality (as it is now) rather than some bodged functionality that meets your particular needs
JonEnstrom
4
Years of Service
User Offline
Joined: 27th Apr 2020
Location:
Posted: 19th Sep 2020 03:12 Edited at: 19th Sep 2020 09:19
I am not sure why you think a function to rotate an object using the shortest path would be "bodged" or why "far more" people would use it to rotate the long way around.. It's an extremely common requirement. That's also why I later mentioned that there could be a flag added to rotate shortest path, or otherwise depending on the requirement. There's no need to be a [MOD EDIT] about it either way.

[MOD: One week ban issued to cool off. Personal insults are not acceptable anywhere on the forum]
This is a breach of article 3.19 of the forum AUP

Login to post a reply

Server time is: 2024-11-21 23:10:47
Your offset time is: 2024-11-21 23:10:47