Re: Simple question - entity orientation

#6
Hi.
For getting the rotation, GetAngles is the right function. But due to a bug, it seems to have problems with values over 90 degree (1/2 * Pi rad).

GetAngles takes a table as a parameter and passes the rotation values into it.

So the following code should work fine:

Code: Select all

local direction = {x=0, y=0, z=0}; GetAngles(direction);
I have not tested the code above, so please forgive me if it doesn't work. I'll look into it tomorrow and test it.

I just hope, that CryTek will provide some sort of LUA integration for backward compatibility in future engine versions.

- Jannis

Re: Simple question - entity orientation

#8
Hi joseph,
I'm not sure *exactly* what you want, but I'm guessing you want to set the angles etc of a spawned entity.
There's probably no reason to get the initial angles as the entity will always have the default angles (its y axis pointing along the Sandbox y axis).
I routinely spawn vehicle entities in my simulator, and also set their positions, angles and any other parameters as needed.
I only use the table to specify the entity class, partly as I'm not familiar with the specification of the entity table (it may not be documented).
.
After spawning it's easy to set parameters for the entity as the function returns the entity ID (MyObject in your example).
So, to set the engles and parameters of a spawned vehicle, I do something like this (pos and angles are set as required):

Code: Select all

local params = {}; params.class="Spitfire"; ID = System.SpawnEntity(params); ID:SetPos(pos); ID:SetAngles(angles); ID.Properties.Stuff = MoreStuff.......etc etc
Hope this helps,
Chris

Re: Simple question - entity orientation

#10
Hi joseph,
Thanks!
One thought occurred. I only use SP, so that method works fine. Presumably it should work by setting the orientation parameters in the table.
But do you know the specific format required? I don't think I ever found documentation on the table.
Cry Engine probably has three methods for setting angles:
Explicit angles, vectors and a third method that uses 4 numbers, not three (I forget the name of this method, but in the past I actually wrote some code to convert from this to more useful angles).
Could it be that the table needs four numbers to set the angles, and not three?
Just a thought.
Regards,
Chris

Who is online

Users browsing this forum: No registered users and 3 guests