Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Change the snake's length
#1
Hello, I tried to change the length of the snake with the cursor, but after changing it once, the snake couldn't trigger other object again.


I used the snake script for the sample scene


Code:
private void BarrierTrigger(object sender, ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();
        for (int i = 0; i < e.contacts.Count; i++)
        {
            var contact = e.contacts.Data[i];
           
            if (contact.distance < 0.005f && interTimer >= interTime)
            {
                interTimer = 0;
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                if (col != null && col.gameObject.CompareTag("Saw"))
                {
                    Debug.Log("Saw");
                    cursor.ChangeLength(rope.restLength - 0.1f);
                }
            }
        }
    }

I found out it was because the snake was closer to the ground than to other objects, so all the collision detected was the ground.

Originally the snake was a little bit away from the ground, but changed its length and it was close to the ground.
What should I do?
Reply