Author Topic: Rotating A Player, Vehicle or other Object the same way round as a brick  (Read 572 times)

I'm making a new mod and I need to know this. I did some research with the dump(); function and came up with these values:
Code: [Select]
// brickrots (%brick.rotation)
// 0 0 -1 90.0002 - west
// 0 0 1 180 - south
// 0 0 1 90.0002 - east
// 1 0 0 0 - north

Using these, how can I rotate objects into these directions? I already checked and there's no setRotation function.

obj.setTransform("125 92 13 0 0 1 90");
The first 3 are the position of the object, the last 4 the rotation.
So that would place obj at 125 92 13 and rotate it to east

obj.setTransform("125 92 13 0 0 1 90");
The first 3 are the position of the object, the last 4 the rotation.
So that would place obj at 125 92 13 and rotate it to east
Oh, ok.

I suppose I can use this if I use getword

Use obj.settransform(obj.getposition() SPC %rot) if you just want to change the rotation

Use obj.settransform(obj.getposition() SPC %rot) if you just want to change the rotation
I don't think bot rotation is the same as brick rotation. :/

here is the function i'm using:
Code: [Select]
function SnapBotToTrack(%this,%track) {
    if(%track.rotation == "0 0 -1 90.0002") {
        %this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "0 0 -1 90.0002");
    }
    if(%track.rotation == "0 0 1 180") {
        %this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "0 0 1 180");
    }
    if(%track.rotation == "0 0 1 90.0002") {
        %this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "0 0 1 90.0002");
    }
    if(%track.rotation == "1 0 0 0") {
        %this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "1 0 0 0");
    }
}

The bot ends up in a wierd diagonal position that doesn't match the brick at all. ):

I'll change the getword stuff for getPosition like you suggested in a minute but I really want to solve this problem first.
« Last Edit: February 28, 2013, 05:04:13 PM by chrisbot6 »

Code: [Select]
%this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "0 0 -1 90.0002");
What the hell are you doing.

Code: [Select]
%this.setTransform(%this.getPosition() SPC "0 0 -1 90");Btw I'm pretty sure the last part of the rotation is supposed to be in radians so that would be
Code: [Select]
%this.setTransform(%this.getPosition() SPC "0 0 -1 1.5707963");And the 0 0 1 180 would be 0 0 1 3.14159265

When getting a rotation with obj.rotation, the last part will be in degrees, when using settransform/gettransform the last part will be in radians. Don't ask why.
« Last Edit: February 28, 2013, 05:17:35 PM by Zeblote »

Code: [Select]
%this.setTransform(getWord(%this.getPosition(),0) SPC getWord(%this.getPosition(),1) SPC getWord(%this.getPosition(),2) SPC "0 0 -1 90.0002");
What the hell are you doing.
being redundant
Code: [Select]
%this.setTransform(%this.getPosition() SPC "0 0 -1 90");Btw I'm pretty sure the last part of the rotation is supposed to be in radians so that would be
Code: [Select]
%this.setTransform(%this.getPosition() SPC "0 0 -1 1.5707963");And the 0 0 1 180 would be 0 0 1 3.14159265

When getting a rotation with obj.rotation, the last part will be in degrees, when using settransform/gettransform the last part will be in radians. Don't ask why.
That would have been nice to know before. Ty

Damn, no good
Code: [Select]
function SnapBotToTrack(%this,%track) {
    if(%track.rotation == "0 0 -1 90.0002") {
        %this.setTransform(%this.getPosition() SPC "0 0 -1 1.5707963");
    }
    if(%track.rotation == "0 0 1 180") {
        %this.setTransform(%this.getPosition() SPC "0 0 1 3.14159265");
    }
    if(%track.rotation == "0 0 1 90.0002") {
        %this.setTransform(%this.getPosition() SPC "0 0 1 1.5707963");
    }
    if(%track.rotation == "1 0 0 0") {
        %this.setTransform(%this.getPosition() SPC "0 0 1 0");
    }
}
if the rotation is "0 0 1 180", it won't even point in remotely the right direction. others however are fine. Help pls ):
« Last Edit: March 01, 2013, 07:11:16 AM by chrisbot6 »