|
|
|
|
Reply From: |
Zylann |
Shape
and its derived classes are resources. Resources can be shared, so you can assign it to multiple CollisionShape
nodes (i.e share it). You will need to create it only once and reduce memory usage, but it will cause twice as much processing in any case (just like it will if you have 10 nodes with the same shape).
I’m not sure what you expect to do in this situation, because if you have an Area and a Body with the same shape, in the same position and same collision masks/layers, they will basically trigger the same events at the same time redundantly, and will indeed be a waste. Better just listen to events from the body and not use an area (if they are configured the same).
OK, I may be getting this whole thing wrong then but what I thought was that in order to get a collision to trigger an event you need to use an area node with a collision shape. When a body or something else enters said area, a signal is sent to a script and a function is triggered.
BUT, a collision shape attached to an area node that sends signals does not work as a physical collider (for rigid/vehicle/etc bodies to collide with, bounce off and so on). I need another collision shape for physical collisions.
Ie, if I want a rigid body to trigger a func when it hits a brick wall (static body) but also want that rigid body to bounce off of that wall, I need that wall object to have 2 collision shapes, one for area (signal) and one for collision.
Or it that not true and I can somehow use one collision mesh for both purposes?
Macryc | 2020-02-11 20:22
Hmm, so how do you detect collision of a rigid body with a static body? I tried:connect("body_entered", self, "_what_happens_on_crash")
I attached it to the rigid body. What happens function was also in the same script. In that function I said: if body.name == “obstacle”: print sth. I then hit the rigid body into the obstacle object but the signal didn’t work…
Macryc | 2020-02-11 21:04
In the RigidBody
inspector, enable Contact Monitor
, and set Contacts Reported
to at least 1.
Zylann | 2020-02-11 21:09
I am glad I asked the question. I’ve now removed so much redundant collision geometry from my level and performance is through the roof!
Thank you!
Macryc | 2020-02-12 06:24