Scripts / Rotation 360 Restrict

Author
Message
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 25th Nov 2019 15:42 Edited at: 25th Nov 2019 16:01
Hi all,

I'm using a complex system that involved an entity, player and camera. I am using all 3 as the player essentially. Things have been going very well positioning wise however with angles it gets a bit complicated.

Quite simply when I rotate the camera, player or entity i dont want to the return value to be greater than 360 or less than -360. In Game Guru when you use the rotation commands it seems to always exceed 360.

I am curious if these commands are the solution?

CurveValue(dest,current,smooth)
WrapValue(y)
WrapAngle ( Angle, Dest, Smoothing )

Wrap Value (y) seems to be the solution but It doesnt seem to work. Kind of wish to the rotation commands themselves when rotating things would not go past 360.

EDIT:
Think i have my solution: (example
CurveAngle(destangle,GetCameraAngleY(0),1)
will convert any number beyond 360 down
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Nov 2019 17:01
does curveangle keep the correct rotation?
i usually use this sort of logic
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 25th Nov 2019 19:07
Curve Angle seems to return the correct rotation.

Basically I'm making a dungeon crawler game that is using a grid-based system 100x100 units. Works out pretty great for Position data as that information is easy for me to work with. Also easy to round up and down to force to the grid if for any reason it falls off.

I actually assumed angles would be easier as I'd just get a return of 90,180,270, 360 (or 0) - multiples of 90. But when I discovered GG goes beyond 360 when you rotate anything in it...that's where my problems began.

Very simply want my North, East, South, West to be designated to figures like 0, 90, 180 and 270. Also, it is easy to get all my creatures knowing what direction they are actually facing in relation to all other entities and the player.
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Nov 2019 22:10
Use quaternions!
Been there, done that, got all the T-Shirts!
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 26th Nov 2019 00:05
Another issue I'm having is how do I know that anything i do isn't just referencing the start of rotation process. Since the values go over. No way to tell if a group of entities are facing one direction?

Mathematically looks like i can round down pretty easily however im worried now that its all working from a rotation anchor point that might not be correct to a global sense of where they are facing.
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 26th Nov 2019 14:10
Got it all sorted it out, indeed with the help of math.
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 26th Nov 2019 16:15
A little bit of this... http://lua-users.org/wiki/SimpleRound
and click = ang/90

PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 2nd Dec 2019 17:32
Thnaks guys I'm going to try all these methods out so I can optimize my code better. As I'm use the way i got it going right now isn't 100% the best way to go about it. Though it works
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960

Login to post a reply

Server time is: 2024-04-26 22:05:51
Your offset time is: 2024-04-26 22:05:51