This module exports a useGizmo
function that enables manipulation of entity position and rotation.
- Download the
object_gizmo
resource. - Extract the
object_gizmo
folder into your server'sresources
directory. - Add
start object_gizmo
to your server'sserver.cfg
file.
exports.object_gizmo:useGizmo(handle)
Ensure the object_gizmo
module script is running on your server.
The useGizmo
export can be used in any Lua script on the client side as follows:
local handle = --[[Your target entity]]
local result = exports.object_gizmo:useGizmo(handle)
result
will contain the entity handle, final position, and final rotation.
This module includes a test command testGizmo
that demonstrates how to use the gizmo.
The command creates an object at the player's location and then activates the gizmo for that object.
local model = `prop_mp_cone_02`
RegisterCommand('testGizmo', function()
local offset = GetEntityCoords(cache.ped) + GetEntityForwardVector(cache.ped) * 3
lib.requestModel(model)
local obj = CreateObject(model, offset.x, offset.y, offset.z, false, false, false)
local data = exports.object_gizmo:useGizmo(obj)
lib.print.info(data)
end)
While using the gizmo, the following controls apply:
- [W]: Switch to Translate Mode
- [R]: Switch to Rotate Mode
- [S]: Switch to Scale Mode (if enabled)
- [Q]: Switch between Relative and World
- [LAlt]: Snap To Ground
- [Enter]: Finish Editing
The current mode (Translate/Rotate) will be displayed on the screen.
The gizmo only works on entities that you have sufficient permissions to manipulate. Make sure you have the correct permissions to move or rotate the entity you are working with.