Flawless? Lol, hardly but I'll take that as a compliment anyway.
Last video for today, this time only one script attached to a single entity but works on all the other active entities on the map, this one is showing off pushing again but this time with rotational component. (i.e. this is the starting point for the module I mentioned earlier)
Here is the script to show what the new commands look like and how they are used ... This script will not work anywhere except on my machine as I haven't pushed the new comands yet, still testing them all! ...
local U = require "scriptbank\\utillib"
function push_init(e)
end
function push_main(e)
local obj = U.ObjectPlayerLookingAt( 200 )
if obj ~= 0 then
-- looking at something
Prompt("Press E to push")
if g_KeyPressE == 1 then
-- need to get push vector
local vx, vy, vz = U.GetViewVector()
-- get scale factors for object
local sx, sy, sz = GetObjectScales( obj )
-- and offsets from centre
local xo, yo, zo = GetObjectCentre( obj )
-- get object position and angle
local ex, ey, ez, xa, ya, za = GetObjectPosAng( obj )
-- work out centre of object
local cx, cy, cz = ex + xo * sx, ey + yo * sy, ez + zo * sz
-- get ray contact points
local rcx, rcy, rcz = GetIntersectCollisionX(),
GetIntersectCollisionY(),
GetIntersectCollisionZ()
-- finally work out contact point offsets from centre
xo, yo, zo = rcx - cx, rcy - cy, rcz - cz
-- and push!
PushObject( obj, vx * 3, vy * 3, vz * 3, xo, yo, zo )
end
end
end
Been there, done that, got all the T-Shirts!