Hi,
I want the player to be able to pick up a rod. I'm checking for pickable objects via spherecasting in front of the player. Unity collider, which are needed for raycasting, are not moving though when attached to a rod. How else could I detect a rod via casting?
greetings
(01-05-2020, 02:31 PM)fishing-rod Wrote: [ -> ]Hi,
I want the player to be able to pick up a rod. I'm checking for pickable objects via spherecasting in front of the player. Unity collider, which are needed for raycasting, are not moving though when attached to a rod. How else could I detect a rod via casting?
greetings
Obi is not made using Unity's physics engine, so particles aren't part of Unity's physics engine (if they were, we would inherit all performance and stability problems of the built-in engine). Using raycasting/spherecasting won't detect them, as casting only works with the built-in Unity physics objects.
Particles use their own collision detection system, here's how you can get all to contacts in a frame and detect Unity objects colliding against particles (trigger colliders work too):
http://obi.virtualmethodstudio.com/tutor...sions.html
(01-05-2020, 02:41 PM)josemendez Wrote: [ -> ]Obi is not made using Unity's physics engine, so particles aren't part of Unity's physics engine (if they were, we would inherit all performance and stability problems of the built-in engine). Using raycasting/spherecasting won't detect them, as casting only works with the built-in Unity physics objects.
Particles use their own collision detection system, here's how you can get all to contacts in a frame and detect Unity objects colliding against particles (trigger colliders work too):
http://obi.virtualmethodstudio.com/tutor...sions.html
I just added Unity colliders to rope and job done!
(01-05-2020, 04:11 PM)Kristaps Wrote: [ -> ]I just added Unity colliders to rope and job done!
Can be done, but kinda defeats the purpose of using particles
.
(01-05-2020, 04:13 PM)josemendez Wrote: [ -> ]Can be done, but kinda defeats the purpose of using particles .
Noo, it's the perfect mix of both worlds!
Before
Obi Ropes, my ropes were made from joints and l
ine renderers ( did not look good and collisions were with gaps )
Now it's totally different and just need to adapt my needs
(01-05-2020, 04:44 PM)Kristaps Wrote: [ -> ]Noo, it's the perfect mix of both worlds!
Before Obi Ropes, my ropes were made from joints and line renderers ( did not look good and collisions were with gaps )
Now it's totally different and just need to adapt my needs
@Kristaps How do you keep the colliders position and orientation in sync with the rope?
(01-05-2020, 05:53 PM)fishing-rod Wrote: [ -> ]@Kristaps How do you keep the colliders position and orientation in sync with the rope?
Made a little helper script:
unityCollider.position = obiActor.GetParticlePosition(obiActor.GetParticleRuntimeIndex(
assignIndex));
assignIndex is the rope particle index
(01-05-2020, 06:34 PM)Kristaps Wrote: [ -> ]Made a little helper script:
unityCollider.position = obiActor.GetParticlePosition(obiActor.GetParticleRuntimeIndex(assignIndex));
assignIndex is the rope particle index
Thank you very much! I guess unityCollider is a transform of a separated GameObject. I attached the collider directly to the rod and change the center. As particles return world space positions I transform them to local space first:
Code:
collider.center = collider.transform.InverseTransformPoint(rod.GetParticlePosition(rod.GetParticleRuntimeIndex(1)));