MSFD Setting position (the other way to do movement)
SetPos, axis, float_enum_pos (float_var with Tribunal/Bloodmoon)
SetPos, z, 477
Object_ID->SetPos X, 466
This function (unlike the move and moveworld functions) also works with Actors, including the player. Axis is x, y, or z. The float value sets the position of the calling object to that value. This always refers to the local coordinate system the object is currently in.
Note: With Tribunal, this function accepts local float variables, but only within the currently active cells. This is relevant for exteriors, you can not move objects an arbitrary distance, the target location must be within the active cells (current cell of player plus surrounding cells). (Forum info / reposted by Srikandi). Also note that while objects can be SetPos to any position (without collision being detected), Actors will still check for collision, and may not move as expected in case of collision (which can be used to good effect for collision detection).
SampleScript: This script is made for floating crates in the Mournhold sewer (Tribunal). It demonstrates how SetPos and SetAngle can be used instead of MoveWorld and Rotate to produce fluid movements:
begin floatAboveStartHeight
float timer
float swingTime
float startAngle
float startHeight
float currangle
float xvalue
float zvalue
float zoffset
float tmpoffset
float weightoffset
float waterlevel
short reset
short initialized
if ( initialized == 0 ); this section stores the starting height and facing of the object
set startAngle to GetAngle, X
set startHeight to GetPos, Z
set swingTime to 1
set initialized to 1
endif
if ( MenuMode == 0 )
set waterlevel to GetWaterLevel
if ( waterlevel > startHeight )
if ( timer == 0 )
if ( reset == 0 )
set timer to Random 100
set timer to timer / 4
endif
endif
set timer to ( timer + GetSecondsPassed )
set currangle to GetAngle X
;These set the amount to move or rotate depending on framerate:
set xvalue to 10 * GetSecondsPassed
set zvalue to 5 * GetSecondsPassed
; the crate sways around its x axis:
;rotate up
if ( timer < swingTime )
set currangle to currangle + xvalue
SetAngle X currangle
set zoffset to zoffset + zvalue
;rotate down
elseif ( timer < (swingTime * 3) )
set currangle to currangle - xvalue
SetAngle X currangle
set zoffset to zoffset - zvalue
;up again
elseif (timer < (swingTime * 4 ) )
set currangle to currangle + xvalue
SetAngle X currangle
set zoffset to zoffset + zvalue
;reset timer to zero
else
set timer to 0
set reset to 1
set zoffset to 0
SetAngle, x, startangle
endif
set tmpoffset to waterlevel
set tmpoffset to tmpoffset + zoffset
; The crate bobs up and down
SetPos Z tmpoffset
Else ; Waterlevel is normal
SetAngle, X, startAngle
SetPos Z startHeight
endif
endif
end