The large amount of lag is purely due to collision detection. In the next coming updates, I would be switching to quadtrees for iterating through the rigidbodies during collision detection, to make the engine 10 times faster!
The 2nd issue is known, well, to be honest that’s just how verlet integration works! A work around would be to set friction of all rigidbodies stacked on top of each other to 0 (RigidBody:SetFriction()) and then set it back to normal when some other body collides with it, etc. But yes, this is something I wish to fix in the future!
Added new example which covers the concept of creating Custom Constraints, where we create the following simulation of a RigidBody hanging from a rope, and wind forces being applied on it.
In the next few updates, I’ll try to implement Quadtrees in the collision detection algorithm to improve performance and make the library 10 times faster!
engine.Started:Connect(function()
-- fires when the engine starts
end)
engine.Stopped:Connect(function()
-- fires when the engine stops
end)
Documentation Updated
Roblox Model and Github Updated
Wally Package Updated - 0.0.5 → 0.1.0
Check out some stuff I made in the past weekend with Nature2D! The game of Plinko and a weight bearing flexible bridge by connecting RigidBodies with constraints!
Quality updates soon. Next updates will be regarding the implementation of quadtrees in collision detection. If anything breaks, open an issue at the github repository!
Quadtrees have now been implemented into the collision detection algorithm making the engine 10 times faster than before. Instead of wasting resources on wasted and unnecessary collision detection checks, RigidBodies are now distributed into different regions of a quadtree with a collision hit range. RigidBodies only in this hit range are processed with collision detection checks. This opens the gate for many new creations that required a larger amount of RigidBodies to be simulated!
Since this is still in beta, there may occur bugs and unwanted behavior. If you encounter any, be sure to open an issue at the github repository. I’ll be adding configuration methods for you to switch between traditional methods of collision detection or quadtrees.
I think it would be nice if you made your Signal API have a public .Connected property, and also so that your Signal destroy method actually loop through the linked list and disconnect everything. Would make behaviour much more consistent with RBXScriptSignals.
Other than that I don’t know what to tell you because I’m not a math person
Good job!
Hey there! Its completely possible to make RigidBodies with different amount of sides. Say triangles, hexagons etc.
While there’s no API that eases this problem, there’s a cheeky way to do it. You create points and constraints to construct the RigidBody, you store those constraints and points in a table, then you create the RigidBody using Engine:CreateRigidBody(). After the Body is initialized, you destroy its UI element and replace its points and constraints with the ones you made earlier. Now, you just need to set the visible property of the constraints to true!
Collisions work for all possible convex shapes. If a concave RigidBody is made, its hitbox will still remain convex.
I may add the official API to make your job easier soon! I’ll attach a placefile for the same if I am able to reproduce the methods above.
p.s. That gif was actually a physics engine made with verlet integration outside of Roblox!
New “restLength” parameter to Engine:CreateConstraint()
Engine:CreateConstraint(Type: string, point1: Point, point2: Point, visible: boolean, thickness: number, restLength: number)
Added rope constraint type
Constraints that have an upper constrain limit and exclusive of a lower limit. Similar to Roblox’s 3D Rope Constraints.
Added rod constraint type
These constraints are similar to how Rope constraints function. But unlike rope constraints, these constraints have a fixed amount of space between its points and aren’t flexible. These constraints can move in all directions just how rope constraints can, but the space between them remains constant.
Added spring constraint type
Spring constraints are elastic, wonky and flexible. Perfect for various simulations that require springs. Achieved using Hooke’s Law.
Type parameter in Engine:CreateConstraint() must be “SPRING”, “ROD” or “ROPE” (text case does not matter).
Spring Constraint Example:
The constraint’s length is randomly set every few seconds.
Previously
Added state management for RigidBodies. Individual RigidBodies can have their own States/Custom Properties now!
Fixed a bug where changes to physical properties before creating any RigidBodies, Constraints or Points won’t affect/apply to newly created objects.
Friction only applies if RigidBodies collide with each other or the edges of the canvas. If none of those conditions are true, AirFriction is applied.
Added AirFriction physical property to Engine, Points and RigidBodies. Frictional force applied when a RigidBody neither touches another body nor the edges of canvas.
Engine:SetPhysicalProperty("AirFriction", 0.1)
Friction and AirFriction are set to 0.01 by default. (0.99 damping value).
Changed how we pass parameters when initializing or updating friction of the engine or rigidbodies. The closer the friction to 1, the higher it is. The closer the friction to 0, the lower it is. Same applies for AirFriction. Values not in the range of 0-1 are automatically clamped down.
Something that I have been wanting to add to RigidBodies, is the flexibility of having any anchor point of the frame and still be able to produce the best simulations. Earlier this was not the case, you could only have the anchor point of 0, 0. Now you can have any anchor point, and rigidbodies will still work as expected!
Added Anchor point support
Added new methods to RigidBodies
RigidBody:GetCenter()
Added new methods to Points
Point:SetPosition(newPosition: Vector2)
Bug fixes
Fixed Parent hierarchy errors in Points.
Fixed Point:Update() “Cannot read property ‘Parent’ of nil” errors.
Fixed Point:KeepInCanvas() “Cannot read property ‘Parent’ of nil” errors.