Scripts / Help wanted please. Camera/ entity angles

Author
Message
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 29th Jan 2019 22:22
Help Wanted. Is there any way to get entity angles in the same format as camera angles?
When I check 'Y' angle of entity, it appears to be in some 90` compass format- very useless to scripting.
ey[e] = GetEntityAngleY(e) ---- returns angles up to 90` then down to 0, then up to 90-- repeat...
When I read camera angle using camera[e] = GetCameraAngleY(0)
, it returns an endless increase or decrease in values. I would like to match this system in reading entity angle.

I would like to match entity angles to camera angles- or rather match the camera angles to an entity angles...
with no confinement to 90 degree compass bearings. Help?

Know which system this uses?
Global= SetCameraAngle : SetCameraAngle ( c, x, y, z ) where c should be zero and XYZ are euler angles

Thank You!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jan 2019 22:43 Edited at: 29th Jan 2019 22:46
Read up on Euler angles!

To convert from Euler angles to 'real world angle' you can use the following: (it's in physlib.lua btw)
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 30th Jan 2019 01:16
Thanks for the response AmenMoses. This will be great. I'll try it out.
To make sure-- that first line makes the call to physicslib.lua? I'm not familiar with the technique.

As I've never got nowhere near this complicated before, this looks a bit beyond me!
, unless I can plug a variable straight into the mix.
I'm guessing 'wrapAng' uses the euler?
Then plug that result into 'getRealWorldYangle'?

I need to use both portions - right? Okay!

I need as much understanding as possible going forward. Much appreciated!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 30th Jan 2019 10:32
Basically just include the code in your script then do:

local angle = getRealWorldYangle( xa, ya, za )

where xa, ya and za are the Euler angles, then angle will contain the 'real world angle' where 0 is 'north' and + values are 'east' and -ve values are 'west'.

The first line is how you include the utillib library as the script uses a function from that library (i.e. the U.Rotate3D bit).
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 1st Feb 2019 01:14
Thanks. I'll see what I can do! TBH though I made a confusing post.
I would really if possible like to convert the compass ie (0 to 90 to 0 to -90)
(these are called real world angles?)-- into euler angles that have infinite increase/ decrease.
and not vice-versa. Would be set then! Anyhow, let me see if I can get this to work.
Thanks!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st Feb 2019 09:55
The Euler angles are limited to the gimbal lock positions (read up on them!).

To do anything constructive you really need to use quaternions, take a look in the pickuppables.lua script to see how they are used.

This might be of help:
https://www.3dgep.com/understanding-quaternions/
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 11th Feb 2019 18:12
Well, I've still been mulling over how we might could rectify this conundrum! lol
I thought I had a solution, but it would require I synchronize both camera and entity angles
to 0 at the beginning of the script-- just to start testing the theory.

(I want the camera to follow the angle of the entity (with some freedom)
Simple right?!

What I need is a SetEntityAngle(e) function-- which does not seem to exist.

Sure there's the GetEntityAngleY(e) function and the GetObjectAngleY(e) , RotateY() functions, etc
but no SetEntityAngle(e) to '#' amount function.

Any suggestions?

I know there are two Zero's (0, north and south), and so I tried 90
--GetCameraAngleY(0) = 90
--GetEntityAngleY(e) = 90

Syntax error it says... ?
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 11th Feb 2019 18:18
AmenMoses-- Also, I thought the solution might reside in your new static_gun script, so I tried
that script out on a level real quick (used the Cross Bow as a weapon) but when I tested it,
the camera view began looking straight up in the sky and turned it seems about 180 degrees
from where I had set it on the map.

So.... still mystified.

Guess I'll test out a few other weapons...?
BTW this line of questioning is primarily for a swimming script.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 11th Feb 2019 18:32 Edited at: 11th Feb 2019 18:47
Is the function I'm looking for called SetRotationY(e)
I'll test that, but if not, hmmm... maybe I could use GetEntityAngleY, and compare it to zero, (or 90)
and if not 90, add or subtract it RotateY(e,v) until equal...? haha
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Feb 2019 20:11
There is a set entity angle function (in fact more than one of them!) it is SetRotation (or ResetRotation).
You have to specify all three Euler angles, camera can be set in the same way but as you can see from static_gun script the SetFreezeAngle and player angles are not Euler angles! (Don't ask me why that may be though)
And to make things more complicated the weapon angles appear flipped 180 degrees from the model angles, confused the hell out of me for a bit that did.

The gimbal lock positions in GG are 'east' and 'west' btw, which is why the Y euler angles go 0 .. 90 .. 0 .. -90 .. 0 (as you turn clockwise) but the player angle just goes 0 .. 359 as you go clockwise.

If you dabble in physics at all you will quickly find out that the Bullet engine is different again btw!

As I said you need to understand Euler angles to make sense of it all!


Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 11th Feb 2019 20:37
Thanks. That's the truth! I'll keep on trecking.

I should have known that cause I messed with the rotation functions a few months ago...
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 11th Feb 2019 21:09 Edited at: 11th Feb 2019 21:13
did you already try SetRotation(e,x,y,z) ? just turn collision off first ( CollisionOff(e) ) otherwise it won't rotate correctly.
are you trying to create a camera system like third person? you will need to offset the camera by a bit too rather than just deal with the Y angle.. something like this

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 12th Feb 2019 01:09
Thanks for the suggestions smallg. What I am trying to do is create a swimming script.
Currently I use the method of "riding" an object-- which can go up and down, left and right
if I ever where to be successful, the object then could be invisible (or very tiny).

So I am using I, J, K, L keys with a swimming stroke of J, L, J, L, J, L... etc, which causes a sinuous swim simulation
when pressed at alternate times. Holding them down causes a tight turn circle, 'K' causes kick straight
and free camera look- (doesn't matter camera angle- you move forward horizontally).
'I' is for diving and upward movement adjusted to go in the direction and angle of where you are viewing.

What I am having trouble with is to tie the camera in with the direction of entity movement. If camera
angle doesn't rotate with the entity in motion, then you would soon find yourself looking behind
the direction of movement, or some random direction, and it would be very confusing to new players.

So I don't want the camera to be rigid, but flexible to a certain degree (literally!) 30-40 deg. Left or right.
I thought it would be all quick, fine and dandy (if the engine methods matched), but I cannot come up
with a technique to accomplish this goal. Thanks for any more help.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 12th Feb 2019 01:12

I downloaded your script, and I'm going to have a look and see if that can help!
Thanks.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 12th Feb 2019 01:27

So in the video, that script matches the "player/ entity" to camera movement- yes?
Camera controls entity rotation. How hard would it be to go the opposite?
Match the entity movement to camera; entity rotation controls camera rotation?
Entity angle can be passed down to the camera angle, controlling the camera
(with #var amount of flexible freedom). Camera angle must be matched to entity angle--
after entity angle is called. That would be perfect.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Feb 2019 01:51
The last time I played with camera control (not player angles but direct camera control) I just used the same angles and IIRC it worked fine.

Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 12th Feb 2019 01:54

No, the keys control the entity, the entity angle is passed to the camera.
Is that right? Interesting. I'm wondering if I can gather number data from this.
I hope! It's hard to follow complex things others have done- but I do appreciate the help.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 12th Feb 2019 02:02

AmenMoses-- well when lil ol' me tried to manipulate the numbers of entity angles
vs camera angles, it didn't work for me! Haha. I never thought of just plugging entity
angles into the camera function....?! Whoa... yeah. Doh. I hope we're on the right track.

Because there are always 2 of every number in the entity angle circle, except for just
one number; 90.
N-E = 0 to 90, E-S = 90 to 0, S-W = 0 to (-90), W-N = (-90 to 0).
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Feb 2019 09:59
Euler, Euler, Euler!

Look at the values of the x & z Euler angles as you rotate an entity around the y axis.
Been there, done that, got all the T-Shirts!
PM
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 14th Feb 2019 23:00 Edited at: 14th Feb 2019 23:00
This might explain the difficulties I'm having with getting the players final camera angle back to horizon after doing an override.



Having difficulties getting the camera to basically reset to horizon. (which im assuming is 180).
Twitter - Teabone3 | Youtube - Teabone3 | Twitch - Teabone3 | TGC Assets - Store Link | Patreon - Teabone3

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: 16th Feb 2019 01:54
Horizon is 0 on X axis.
yeah, -80 is full up, 85 is full down, 0 = horizontal
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 16th Feb 2019 02:00
So... what part of the video was of issue? Starting to climb the ladder?

When I "over ride" the engine camera, which I never call to CameraOveride function--
I just simply change camera angle, as soon as no more camera script is active,
regular control is given back to mouse camera movement.

Camera Angles are very simple and intuitive. They are very useful. It's the part of matching
the camera angles to the entity angles which are 2 very different creatures from different planets.
I can't get a grip on how it might be done. Will need some proper study.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 8th May 2019 21:43
Cool!
PM

Login to post a reply

Server time is: 2024-12-22 14:02:14
Your offset time is: 2024-12-22 14:02:14