Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Changing rope length using variable
#4
(23-02-2023, 11:35 AM)rohit_dhak Wrote: I have a pool particle size of 1000.

Unity was just freezing whenever it would try to run the
Code:
set_control()

from the set_control() function, I removed the check condition
Code:
        while (c1_len != c1_control_ip)

Unity froze in that while loop for an obvious reason: neither variable used as the condition to break the loop (c1_len and c1_control_ip) changes once inside the loop. So once execution enters the loop, it will never exit.


(23-02-2023, 11:35 AM)rohit_dhak Wrote: However it just set the rope length instantly and did not change it continuously over time from the current length.
Any idea on how to achieve that.

This is a basic programming question, not really related to Obi. If you want to increase a variable, you just add a value to it using the "+" operator.
Something like:

Code:
ropeLength = ropeLength + increment;
cursor.ChangeLength(ropeLength);

To make it frame rate independent, just multiply the increment by the time passed since the last frame:

Code:
ropeLength = ropeLength + increment * Time.deltaTime;
cursor.ChangeLength(ropeLength);

You have a working example of this in the included "Crane" sample scene.
Reply


Messages In This Thread
RE: Changing rope length using variable - by josemendez - 23-02-2023, 11:43 AM