Closed jaipack17 closed 2 years ago
Looks like there hasn't been much activity going on here! In order to prevent clutter and purge inactive issues, this issue will be closed if it remains in the state of inactivity. If your issue has not been solved, you can open another issue to address your query! Be sure to format your issue correctly to help us review and process your issue faster!
Regarding the possible addition of the new CanTouch property for RigidBodies.
At present each RigidBody has a
Collidable
property which is a boolean. This property determines if collision detection will be processed for the rigidbody and if .Touched, .TouchEnded and .CanvasEdgeTouched events will be fired.Each frame when collisions are detected and processed, any Rigidbody whos Collidable property is set to false will be ignored. The idea of CanTouch is to detect collisions between the RigidBodies even if Collidable is false. If two RigidBodies collide, and either or both of them have their Collidable property set to false but CanTouch as true, .Touched will be fired but no separating/collision response force will be applied to them. This also relates to .CanvasEdgeTouched. Even if KeepInCanvas is set to false, .CanvasEdgeTouched will still fire but forces to keep the RigidBody inside the canvas won't be applied.
There are a few concerns and questions which emerge with such a change. So before adding this functionality, I'd like to hear from you on these points.
Considering how expensive collision detection is, would it be feasible to detect collisions by default between RigidBodies even if their Collidable properties are set to false? Should CanTouch be false for Non-Collidable bodies by default? I wouldn't want to sacrifice performance for a simple feature.
Would it be worth adding a property which introduces performance issues, if using methods that are already available to you can be used even if Collidable is set to false? Detecting collisions between two RigidBodies irrespective of their Collidable property, can be done with
RigidBody:DetectCollision(otherBody: RigidBody)
. Hence, your own custom implementation of .Touched can be made for non-collidable rigidbodies. This can help save up on unnecessary collision detection checks.As far as .CanvasEdgeTouched is concerned, even if KeepInCanvas is set to false, you could loop through the vertices of the RigidBody to see if any one of them crosses/touches any edge of the canvas and create a custom implementation of .CanvasEdgeTouched.
RigidBody:IsInBounds()
can also be utilized. Which once again saves on collision detection checks.So I'm pretty sceptical about this addition. Though it may be deemed helpful to many because of how convenient and easy collision detection for Non-Collidable RigidBodies will be. Would this property be useful? Let me know if you have any questions, feedback or answers.