I'd like to create a configurable joint where two objects collide...
As the title says, I would like to create a configurable joint precisely where two objects collide.
For the moment, I use the midpoint between the two colliding objects center as an anchor point. Result is nice but unpredictable for any object that is not spherical... So ideally having the contact point as an anchor would be better.
I have a function that create a joint on click (vive controller) between to grabbed objects.
I know I have to use "OnCollisionEnter" to get the contactpoints between the two colliding objects.
But I am unsure of how to send these coordinates from the colliding objects (Gameobjects with OncollisionEnter) to the script that create joints (on the controller) and for the whole thing to fire up only when I click...
I know this is old and you likely have an answer at this point but could you share your code? I am curios to see how you are creating the joint on click.
For the collision point have you tried something like:
void OnCollisionEnter (Collision collision) {
if (collision.rigidbody != null) {
ContactPoint contact = collision.contacts[0];
Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
Vector3 pos = contact.point;
GameObject impactGO = Instantiate(joint, pos, rot);
}
}
Your answer
Follow this Question
Related Questions
Case of the Haunted Standard Car Assets? 0 Answers
RigidBody's Center Of Mass doesn't always update properly 1 Answer
Can you point me in the direction of how to get space physics like the one in this video? 1 Answer
Raycast detecting colliders issue w/ image depicting problem 0 Answers
Changing direction of a hing joint 1 Answer