Game Development Reference
In-Depth Information
local cameraForward =
Sandbox.GetCameraForward(sandbox);
-- Offset the block's position in front of the
camera.
local blockPosition =
cameraPosition + cameraForward * 2;
local rotation =
Sandbox.GetCameraOrientation(sandbox);
-- Mass of the block in kilograms.
Core.SetMass(block, 15);
Core.SetRotation(block, rotation);
Core.SetPosition(block, blockPosition);
-- Applies instantaneous force for only one update
tick.
Core.ApplyImpulse(
block, Vector.new(cameraForward * 15000));
-- Applies instantaneous angular force for one
update
-- tick. In this case blocks will always spin
forwards
-- regardless where the camera is looking.
Core.ApplyAngularImpulse(
block, Sandbox.GetCameraLeft(sandbox) * 10);
end
end
If we run the sandbox now, we can move around, point the camera, and shoot blocks.
Search WWH ::




Custom Search