The SFramework Physics Manager handles storing references all physics objects in a scene as well as handling collision detection and resolution for Physics objects. While most developers will not likely ever need this API, as it is mainly used under the hood in the Physics component, it is still available to use if there is ever a case that someone may need it.
SFPhysicsManager.physicsObjects
Adds the given GameObject with Physics component to the manager’s table of Physics objects
obj
- GameObject
(required) the object to add
SF.physics.manager:AddPhysicsObject(self.gameObject)
Removes the given GameObject from the manager’s table of Physics objects
obj
- GameObject
(required) the object to remove
SF.physics.manager:RemovePhysicsObject(self.gameObject)
Returns a table with collision depth and normal for the two given objects or nil
if no collision
obj1
- GameObject
(required) the first GameObject to checkobj2
- GameObject
(required) the second GameObject to check
local myCollisionData = SF.physics.manager:GetCollisionData(self.gameObject, CS.FindGameObject("other object"))
if myCollisionData ~= nil then
print("Collision depth: "..myCollisionData.depth)
print("Collision normal: "..myCollisionData.normal)
end
Resolves the collision between the two given objects with the given collision data
obj1
- GameObject
(required) the first GameObjectobj2
- GameObject
(required) the second GameObjectdata
- CollisionData
(required) the collision data
local myOtherObject = CS.FindGameObject("other object")
local myCollisionData = SF.physics.manager:GetCollisionData(self.gameObject, myOtherObject)
if myCollisionData ~= nil then
SF.physics.manager:ResolveCollision(self.gameObject, myOtherObject, myCollisionData)
end