Obi Official Forum
Help Change the snake's length - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Change the snake's length (/thread-3015.html)



Change the snake's length - zxcasd654 - 08-07-2021

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?