jaipack17 / Nature2D

A 2D physics engine for Roblox. Create versatile physics simulations and mechanics with GUIs!
https://jaipack17.github.io/Nature2D/
MIT License
147 stars 8 forks source link

Get name of obj that touched the rigidbody using .Touched #51

Open NuggetXX2000 opened 9 months ago

NuggetXX2000 commented 9 months ago

Description

What do you need help with/what is your query? Describe in 30-40 words or more!

When using .Touched, I am unable to get the name of the obj that has touched the rigidbody

example: sprite.Touched:Connect(function(id) objTouched = engine:GetBodyById(id) print(tostring( objTouched.Name )) -- Returns nil, I've tried many other ways but it returns a table value or just the id end)

So far I have

What have you tried so far? (Optional)

Searched online, searched nature2d forum

Lastly

Anything else you would like to share?

If this is an easy fix I'll feel stupid

Rulyns commented 1 month ago

Hey, I dont know if you still need this info. But After you initiate the object, you can add additional properties such as Name. Here's my example: melon.Name = "mel" print(engine:GetBodyById(melon.id).Name)

You would call this AFTER you create an object through Engine:Create(), this is NOT something you type when you're creating the object, just right after

NuggetXX2000 commented 1 month ago

Hey, I dont know if you still need this info. But After you initiate the object, you can add additional properties such as Name. Here's my example: melon.Name = "mel" print(engine:GetBodyById(melon.id).Name)

You would call this AFTER you create an object through Engine:Create(), this is NOT something you type when you're creating the object, just right after

Thanks! I have since put off the project but whenever I get the chance to, I will use this and let you know. Thanks again.