Hi, im placing an item at outpost, its been ok for a few wipes now, im using
Vector3 finalPosition = ma.TransformPoint(relativePosition);
and its spawning ok, no prob, but i have to manually change the rotation each wipe. in the code i just keep incrementing the rotation and respawning till its good
float thisWipesRotation = 231f;
...
oATM.transform.Rotate(0.0f, thisWipesRotation , 0.0f, Space.Self);
i see MonumentAdapter has a Rotation, but i cant wrap my head round using it correctly, (new to unity.. )
have you got a suggestion i could try? ta
Finding RotationSolved
Deleted
Merged post
just clarifying (more for my own sake :))
so (this map) i use
float thisWipesRotation = 231f;
...
oATM.transform.Rotate(0.0f, thisWipesRotation , 0.0f, Space.Self);
(i tried oATM.transform.Rotate(0.0f, thisWipesRotation , 0.0f, Space.World); but no difference)
but i cant find a way to get that 231 value from my MonumentAdapter
if i run
MonumentAdapter ma = GetCompound();
Puts(ma.Rotation.ToString());
it outputs
(0.0, 1.0, 0.0, 0.0)
MonumentAdapter ma = GetBandit();
Puts(ma.Rotation.ToString());
gives
(0.0, 0.7, 0.0, 0.7)
i think the missing bits in my head are, is ma.Rotation actually what im after? and if so, how do i transform it to what i need?
ta
You have to determine the relative rotation them multiply that by the Monument rotation to determine the rotation that you should spawn the entity at. If you have an existing entity and want to determine its relative rotation, multiply its rotation by the inverse of the monument's rotation using Quaternion.Inverse.
ok :) thank heaps,
Merged post
i havent cracked it yet,
im getting the position i want it, against the side of a building in outpost
Quaternion relativeRotation = new Quaternion(0,146,0,1);
then multiplying it by the monuments rotation
Quaternion worldRotation = ma.Rotation * relativeRotation;
then i rotate the object
oAtm.transform.Rotate(0, worldRotation.y, 0);
but its different between 2 maps
im not sure im creating relativeRotation right tho
do you know what im doing wrong? ta
Merged post
sorry above, first lines should read
im getting the rotation i want, nicely against the side of a building in outpost
Quaternion relativeRotation = new Quaternion(0,146,0,1);
You should not create Quaternions via constructor. You should describe your rotation as euler angles, like Quaternion.Euler(0, 45, 0). When you determine the relative rotation from the world world rotation, convert that back to euler angles and persist the result somewhere (such as hard coded or in a data/config file). The code in Monument Addons already does this correctly, you just need to find the right places.
I DID IT!!! thanks very much, sitting against the wall nicely on 2 different maps.
MonumentAdapter ma = GetCompound();
Quaternion relativeRotation = Quaternion.Euler(0, 270, 0);
Quaternion worldRotation = ma.Rotation * relativeRotation;
...
oAtm.transform.rotation = worldRotation;