Nature2D - 2D Physics Engine for UI Elements

Yep, its a bug. Thanks for reporting! I’ll fix this up in the next release :slight_smile:. It was a problem in the code itself.
image

2 Likes

Thank you!

Also, quick question, is there support for registering collisions on objects with Collidable = false? I have a special case where I want an action to happen if a collider goes through an object without Collision, and I noticed the .Touched event doesn’t fire. Is there some way to register them or disable a check? If there isn’t, that’s fine, it’d just be nice to know.

Collidable is like CanTouch & CanCollide combined together. Hence .Touched and .CanvasEdgeTouched only fire if Collidable is true. This may be a design flaw. It’d make sense to add a CanTouch property to the RigidBodies and treat Collidable as CanCollide. I’ll be sure to look into it for the next release!

Alright, cool! Thanks for the quick responses!

Also, sorry for the barrage of replies, but is there a way to invalidate a RigidBody without removing the GuiObject it affects? For example, say I had a frame which was affected by a RigidBody. Is there a way to stop it from being simulated like one without destroying the frame itself?

Thanks for all your help!

A hacky way of doing this would be to loop through the RigidBodies of the Engine and remove the one you want manually:

local id = "id of the rigidbody you want to remove"

for i, b in ipairs(Engine.bodies) do 
   if b:GetId() == id then 
       table.remove(Engine.bodies, i)
   end
end

I am not exactly sure if this makes any errors pop up though!

No worries! I am thankful that you’re pointing out and suggesting some actually important features and design flaws that should’ve been kept in mind earlier. Thanks again! And I’ll be sure to add an easier way to do this in the next release. :grin:

v0.5.3 - Improvements to .Touched Event.

  • Improvements to .Touched Event. The event does not fire every frame anymore if two bodies are colliding. It’ll only fire the moment the two bodies collide. Playing collision sounds etc is now possible.
  • RigidBody:Destroy() now takes in an optional argument “keepFrame: boolean|nil”. If passed in as true, the RigidBody’s UIElement will not be destroyed. If passed as false or nil, the RigidBody’s UIElement will be destroyed along with it.
  • Changes to Signal utility. Curtsy of @LucasMZ_RBX
    • Made Connection property .Connected public

Updated Roblox Asset & Github

Updated Documentation

Updated Wally Package - 0.5.2 → 0.5.3



The ability for Anchored RigidBodies to have different anchor points will be added soon. CanTouch property needs to be revised before being added since I wish to maintain less collision detection checks each frame!

2 Likes

Great! This adds a lot of great features. I appreciate your effort and response to feedback!

By the way, since the .Touched event no longer fires every frame, is there a way to detect when a touch ends (like Roblox’s BasePart .TouchEnded event)?

Not currently, will think about adding it. Thank you for the suggestions :slight_smile:

2 Likes

v0.5.4 - TouchEnded Event

  • Added .TouchEnded event to RigidBodies. This event fires the moment two RigidBodies stop colliding with each other.
  • SomeRigidBody.TouchEnded:Connect(function(otherID)
        local OtherRigidBody = Engine:GetBodyById(otherID)
        print("Touch ended")
    end)
    
  • Fixed AnchorPoint bug with anchored RigidBodies. Anchored RigidBodies can now have any AnchorPoint, which does not affect how they are positioned on the screen. cc: @Inconcludable

Updated Roblox Asset & Github

Updated Documentation

Updated Wally Package - 0.5.3 → 0.5.4


3 Likes

A quick demo for this:

image

2 Likes

Thank you so much!! I’ve never seen a resource creator that responds to feedback as much as you do. These events should make my game easier to make, so I appreciate your hard work!

2 Likes

I wish to hear your thoughts on a CanTouch property for RigidBodies that may be added in the future if a majority agrees. This feature is quite useful but has some drawbacks.

View the issue linked below for more information.

1 Like

May I ask, how do we add plugins to that module?

1 Like

If you’re creating a plugin for yourself/locally then follow whatever coding pattern you wish to use.

If you’re wanting to add a plugin to the original library, which is for something that would take a lot of effort to make from scratch, but is easier to do with the help of your plugin. Then, fork the github repository, create the new plugin file under src/Plugins and follow the given code structure:

return function (...)
    -- plugin code
end

After you’ve completed coding the plugin module, go to src/Plugins/init.lua and add your plugin to the dictionary that is returned.

image

Something like:

Hexagon = require(script.Hexagon) -- src/Plugins/Hexagon.lua

After you’ve made the required changes, open a pull request in the main repository. It’ll be merged and added to the library. You can take a look at other plugin modules for reference as well.

2 Likes

v0.5.5 - A new look for Spring Constraints

  • Fixed bug where setting Visible to true when creating a custom constraint won’t render the constraint on screen.
  • Spring Constraints now use a Coil ImageLabel instead of a straight line when rendered for better visual distinction between springs, ropes and rods.

    NUEeFzjp9j__online-video-cutter_com__SparkVideo

Updated Roblox Asset & Github

Updated Documentation

Updated Wally Package - 0.5.4 → 0.5.5


5 Likes

That’s fantastic; what else are you working on?

At present I’ve been working on supporting methods like :Clone(), :SetSize(), :SetPosition(), :Rotate() etc for Custom RigidBodies. Looking into creating more types of constraints. And also some other fixes, improvements and features!

I’ll surely look it over when you’re finished. I’m looking forward to seeing what you come up with.

1 Like

v0.5.6 - Engine:GetDebugInfo(), Engine.Updated and bug fixes

  • Bug Fixes
    • Rope constraints were completely broken and was unaware about it until I tested them yesterday. They have been fixed. Turns out there was a mistake in the force calculation.
    • Fixed KeepInCanvas property not working for RigidBodies when using Engine:Create()
  • Added Engine:GetDebugInfo()
  • Removed Engine:GetCurrentCanvas() - Deprecation Warning.
  • Added new event Engine.Updated
    • Engine.Updated fires each frame. It fires the moment all physics objects have been updated and rendered on screen.
    Engine.Updated:Connect(function()
        -- do something
    end)
    
  • Updated documentation and tutorials subsequently.

Updated Roblox Asset & Github

Updated Documentation

Updated Wally Package - 0.5.5 → 0.5.6


1 Like

Made several changes and improvements to the documentation site!

1 Like