- Home /
Collision normals changing based on player position
Hi, I'm working on a project with the Novint Falcon right now. I'm using a C# wrapper I found on these forums, but that's not the problem. Right now I have a fist that I'm using to smack into a cube and apply force back. I can detect the collision successfully, but when I apply the force back to the Falcon, it'll only put it in the right direction if I'm facing in the same orientation as the cube I'm hitting. The first picture shows the orientation where the correct force is applied, the second is where the incorrect force is applied. They're kinda hard to see but the top has the cube to the right, the second the cube is to the left.
When I print the normal of the contact points of each collision, they are the same. Could it be my coordinates that are messing everything up?
Here's some code:
internal void SetServoPos(Vector3 pos, double strength)
{
double[] _pos = new double[3];
_pos[0] = pos.x;
_pos[1] = pos.y;
_pos[2] = pos.z;
SetServoPos(_pos, strength);
}
void OnCollisionEnter(Collision other2)
{
print("First normal of the point that collide: " + other2.contacts[0].normal);
foreach(ContactPoint contact in other2.contacts){
Debug.DrawRay (contact.point,contact.normal,Color.green,5,false);
}
SetServoPos(other2.contacts[0].normal,2);
}
void OnCollisionExit(Collision other1)
{
SetServoPos(new double[3]{0,0,0},0.5);
}
void Update ()
{
gameObject.transform.localPosition = new Vector3( (float)GetXPos(), (float)GetYPos(), (float)GetZPos()*-1 + 3);
//Debug.Log ( isButton0Down() + " , " + isButton1Down() + " , " + isButton2Down() + " , " + isButton3Down() );
}
Any help would be appreciated. Thanks!
Your answer
Follow this Question
Related Questions
Problem with custom raycast2D collision detection system. 1 Answer
Getting surface normal from collision 1 Answer
Direction/Hit Detection without triggers. 1 Answer
Using Raycasts to change the X and Y position of a moving GameObject? 1 Answer
Rigidbodies won't collide if mass difference is too high 0 Answers