Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add consintent speed/velocity to a rope?
#1
I tried with this:



private void AddVelocityToRope(float scale)
{
    var verticalActionValue = Input.GetAxisRaw("Vertical");
    var shiftPressed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

    if (verticalActionValue != 0 && shiftPressed)
    {
        var downPressed = verticalActionValue < 0;
        var s = 1;
        if (downPressed) s = -1;
        var bodyForward = _playerController.animator.bodyRotation * Vector3.forward * s;

        //SetRopeInvMasses(1 / mass);

        //igy egyenesebb a kotel mozgasa, mintha csak 1-et adnank at
        for (var i = 0; i < rope.elements.Count; i++)
        {
            var addVelocity = (bodyForward * (scale * 10f * maxRopeVelocityScale)).ToVector4();
            var v = solver.velocities[rope.elements[i].particle2];
            if (v.magnitude <= _newDamping * 2) solver.velocities[rope.elements[i].particle2] += addVelocity * (Time.deltaTime * 10);
        }
    }
}




But I get not the desitred behaviour.



So how can I add a consistent velocity to all my particles?



+1: How can I ignore bigger velocities than a limit? Sometimes just the rope immediatelly get a big velocity I don't know why...and the rope is just jumping..
Reply


Messages In This Thread
How to add consintent speed/velocity to a rope? - by lacasrac - 04-10-2023, 05:16 PM