Author Topic: rotate to face a definite point  (Read 2002 times)

i feel like there are a million instances and questions about this but i can't find anything worthwhile anywhere

google returns unity stuff but they all use fansy unity lookat functions and we don't have that luxury

tried a few different things and now i'm stuck help mom

the end application will deal with camera views but we can't use orbit functionality in this scenario; we're looking to deal with transform values. this would also make it more useful for future applications


Look at the default camera events.

Port was able to achieve this with a static shape.

http://forum.blockland.us/index.php?topic=230647.msg6550363#msg6550363
i looked at that and it didn't appear to work for some reason

Look at the default camera events.
this worked, thanks

Code: [Select]
function ShapeBase::PointAt(%this, %pos)
{
%thispos = %this.getPosition();
%delta = VectorSub(%pos, %thispos);
%dX = getWord(%delta, 0);
%dY = getWord(%delta, 1);
%dZ = getWord(%delta, 2);
%hyp = VectorLen(%dX SPC %dY SPC 0);

%rotZ = mAtan(%dX, %dY) * -1;
%rotX = mAtan(%dZ, %hyp);

%this.setTransform(%thispos SPC eulerRadToMatrix(%rotX SPC 0 SPC %rotZ));
}
« Last Edit: September 23, 2014, 02:03:02 PM by otto-san »

This will be useful. I can implement this into my vehicle flip script to right vehicles facing in the same direction as they face when upside down.