if you move something using SetPosition then you should call ResetPosition (and same for SetRotation and ResetRotation) to update the physics to match its new location/rotation
nice script amen
not a very good "roll" but may help point you in the right direction
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
local U = require "scriptbank\\utillib"
local Q = require "scriptbank\\quatlib"
local rad = math.rad
local deg = math.deg
rotating = 0
result = 0
function dice_throw_init( e )
Include( "utillib.lua" )
end
function dice_throw_main( e )
if startax == nil then
startax = g_Entity[e]['anglex']
startay = g_Entity[e]['angley']
startaz = g_Entity[e]['anglez']
startx = g_Entity[e]['x']
starty = g_Entity[e]['y']
startz = g_Entity[e]['z']
end
-- get new Euler angles
if rotating == 0 then
CollisionOn(e)
if g_Scancode == 18 then
result = 0
rotating = 200
SetRotation(e,startax,startay,startaz)
SetPosition(e,startx,starty,startz)
ResetPosition(e,startx,starty,startz)
ResetRotation(e,startax,startay,startaz)
rx = math.random(1200,1600)
ry = math.random(200,600)
rz = math.random(200,600)
end
elseif rotating > 0 then
CollisionOff(e)
rotating = rotating-1
MoveUp(e,2)
RotateX(e,rx)
RotateY(e,ry)
RotateZ(e,rz)
CollisionOn(e)
end
local xa, ya, za = rad( GetEntityAngleX( e ) ), rad( GetEntityAngleY( e ) ), rad( GetEntityAngleZ( e ) )
local vx,vy,vz = U.Rotate3D(0,0,1, xa, ya, za)
if rotating == 0 and g_Entity[e]['y'] <= starty+20 then
if vy > 0.5 then
PromptLocal(e, "4")
result = 4
elseif vy < -0.5 then
PromptLocal(e, "3")
result = 3
end
end
vx,vy,vz = U.Rotate3D(0,1,0, xa, ya, za)
if rotating == 0 and g_Entity[e]['y'] <= starty+20 then
if vy > 0.5 then
PromptLocal(e, "6")
result = 6
elseif vy < -0.5 then
PromptLocal(e, "1")
result = 1
end
end
vx,vy,vz = U.Rotate3D(1,0,0, xa, ya, za)
if rotating == 0 and g_Entity[e]['y'] <= starty+20 then
if vy > 0.5 then
PromptLocal(e, "2")
result = 2
elseif vy < -0.5 then
PromptLocal(e, "5")
result = 5
end
end
if result > 0 then
Prompt("Result = "..result)
end
end