I have a question about raycastFirst, I don’t know if I’m using it well or if I should change to another method, I hope you can help me.
First I want to tell you what I want to achieve:
-I want to do a knife attack, but I can’t use COLLIDER because my player entity already uses a “COMPOUND” type COLLIDER and since the knife entity is attached to the character it makes the player entity detect the knife COLLIDER as part of the character , that’s why I decided to use raycastFirst, why it seems like a good option for performance (according to me), but I have a problem that I do not know how to solve, I will show it with images so that it is better understood (I hope so).
-
This is my model of a wheel
-
This wheel model has a COLIDER
-
This is my knife that has a script for it to run a raycastFirst on “UPDATE” and detect if it touches something (that I want to change it to activate when the weapon is used and deactivate if not)
-
Now when the raycastFirst of the knife touches the COLIDER of the wheel, everything works fine, it detects it while it is in contact (it can be seen in the command console)
-
Here comes my problem, when all the raycastFirst is inside the COLIDER it does not detect it, and when my player executes an attack, if all the raycastFirst enters the COLIDER it is as if it was deactivated, because it no longer makes contact
Well those are all the images -
My question is if this is how raycastFirst should act or if I’m using it wrong (I don’t know much about this topic).
-
My other question is if the way I’m using it is wrong and, contrary to what I think, it requires a lot of performance.
-
My other question is whether the COLIDER option is better, that is to create a COLIDER and not attach it to the knife, but to the “ROOT”.
This is my scene in case you want to keep an eye on it, the entities are in root and are called
wheel_0 and knife_0
https://playcanvas.com/editor/scene/1068306
I hope you can help me and thanks for reading to the end.