You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DefoldDocs/api/collision_object.lua
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,11 @@ function physics.destroy_joint(collisionobject, joint_id) end
36
36
---@returnvector3 gravity vector of collection
37
37
functionphysics.get_gravity() end
38
38
39
+
---Returns the group name of a collision object as a hash.
40
+
---@paramurlstring|hash|url the collision object to return the group of.
41
+
---@returnhash hash value of the group. function checkIsEnemy() local grp = physics.get_group("#collisionobject") assert( grp == hash("enemy") ) end
42
+
functionphysics.get_group(url) end
43
+
39
44
---Get a table for properties for a connected joint. The joint has to be created before
40
45
---properties can be retrieved.
41
46
---Note: Currently only supported in 2D physics.
@@ -60,6 +65,13 @@ function physics.get_joint_reaction_force(collisionobject, joint_id) end
60
65
---@returnfloat the reaction torque on bodyB in N*m.
61
66
functionphysics.get_joint_reaction_torque(collisionobject, joint_id) end
62
67
68
+
---Returns true if the specified group is set in the mask of a collision
69
+
---object, false otherwise.
70
+
---@paramurlstring|hash|url the collision object to check the mask of.
71
+
---@paramgroupstring the name of the group to check for.
72
+
---@returnboolean boolean value of the maskbit. 'true' if present, 'false' otherwise. function checkCollideWithUser() -- to check if the collisionobject would collide with "user" group local hits_user = physics.get_maskbit("#collisionobject","user") return hits_user end
73
+
functionphysics.get_maskbit(url, group) end
74
+
63
75
---Ray casts are used to test for intersections against collision objects in the physics world.
64
76
---Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
65
77
---do not intersect with ray casts.
@@ -95,6 +107,13 @@ function physics.raycast_async(from, to, groups, request_id) end
95
107
---@paramgravityvector3 the new gravity vector
96
108
functionphysics.set_gravity(gravity) end
97
109
110
+
---Updates the group property of a collision object to the specified
111
+
---string value. The group name should exist i.e. have been used in
112
+
---a collision object in the editor.
113
+
---@paramurlstring|hash|url the collision object affected.
114
+
---@paramgroupstring the new group name to be assigned. function changeCollisionGroup() physics.set_group("#collisionobject", "enemy") end
115
+
functionphysics.set_group(url, group) end
116
+
98
117
---Flips the collision shapes horizontally for a collision object
99
118
---@paramurlstring|hash|url the collision object that should flip its shapes
100
119
---@paramflipboolean true if the collision object should flip its shapes, false if not
@@ -108,6 +127,12 @@ function physics.set_hflip(url, flip) end
108
127
---@parampropertiestable joint specific properties table Note: The collide_connected field cannot be updated/changed after a connection has been made.
109
128
functionphysics.set_joint_properties(collisionobject, joint_id, properties) end
110
129
130
+
---Sets or clears the masking of a group (maskbit) in a collision object.
131
+
---@paramurlstring|hash|url the collision object to change the mask of.
132
+
---@paramgroupstring the name of the group (maskbit) to modify in the mask.
133
+
---@paramtypebool boolean value of the new maskbit. 'true' to enable, 'false' to disable. function makeUserAlly() -- no longer collide with the "user" group physics.set_maskbit("#collisionobject","user",false) end
134
+
functionphysics.set_maskbit(url, group, type) end
135
+
111
136
---Flips the collision shapes vertically for a collision object
112
137
---@paramurlstring|hash|url the collision object that should flip its shapes
113
138
---@paramflipboolean true if the collision object should flip its shapes, false if not
0 commit comments