How to rest all state - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html) +--- Thread: How to rest all state (/thread-865.html) |
How to rest all state - _gaoyu_ - 02-02-2019 I disable ObiActor and rest partcle position . wait 0.5 second , I enabled ObiActior ,but I found previous Acceleration still exist. Why? code: GetComponent<ObiActor>().enabled = false; GetComponent<SkinnedMeshRenderer>().enabled = false; transform.position = new Vector3(Random.Range(-4.0f,4.0f),1.5f,Random.Range(-4.0f,4.0f)); GetComponent<ObiActor>().Solver.positions[pId] = transform.position; GetComponent<ObiActor>().Solver.velocities[pId] = new Vector3(0.0f,0.0f,0.0f); yield return new WaitForSeconds(0.5f); GetComponent<ObiActor>().enabled = true; GetComponent<SkinnedMeshRenderer>().enabled = true; RE: How to rest all state - josemendez - 03-02-2019 (02-02-2019, 02:33 PM)_gaoyu_ Wrote: I disable ObiActor and rest partcle position . wait 0.5 second , I enabled ObiActior ,but I found previous Acceleration still exist. Why? Hi, Also set prevPositions to the same as positions, since velocities are calculated using differentiation: new velocity = (position - previous_position) / delta_time. RE: How to rest all state - _gaoyu_ - 04-02-2019 (03-02-2019, 02:13 PM)josemendez Wrote: Hi, I try to rest prevPositions, but no change RE: How to rest all state - josemendez - 04-02-2019 (04-02-2019, 09:52 AM)_gaoyu_ Wrote: I try to rest prevPositions, but no change Hi there, I'm assuming you want to teleport the object to a new position, right? In that case, you cannot set all particles to the same position. This will result in the object collapsing to a single point, then "exploding" after moving to the new location and gaining momentum in a random direction. You need to calculate their position relative to the transform prior to teleporting, then adding these delta positions to the new object position. Something like this: Code: using System.Collections; RE: How to rest all state - _gaoyu_ - 05-02-2019 Hi josemendez, I upload my test file and link: https://pan.baidu.com/s/1e8jU5dDUlEoZSLhKrK7VXg I want to rest postion and Acceleration , but still failure. Every ball will rest pos when y<-5.0 ,but Velocity is error. My idea is ball will vertical fall after rest; You can check AddRandomVelocity.cs, KeyCode.Space can force balls. Please Thankyou RE: How to rest all state - josemendez - 05-02-2019 (05-02-2019, 06:13 AM)_gaoyu_ Wrote: Hi josemendez, Hi, Sorry, I'm unable to download the file you sent. The script I posted in my previous post will move the object to a random position, and it will of course fall due to gravity after being moved to a new position. Make sure you have deactivated the AddRandomVelocity script in the ball pool scene (or at least commented out its original code), as that will set a random velocity for all soft bodies in the scene when you press "space". Also, make sure "Simulate when invisible" is enabled in the ObiSolver settings. When disabled, the solver will cease to perform simulation once all objects are invisible to all game cameras. RE: How to rest all state - _gaoyu_ - 05-02-2019 (05-02-2019, 08:57 AM)josemendez Wrote: Hi, Hi, Can you give me your email? RE: How to rest all state - josemendez - 05-02-2019 (05-02-2019, 10:18 AM)_gaoyu_ Wrote: Hi, Yes, it's support(at)virtualmethodstudio.com or obi(at)virtualmethodstudio.com RE: How to rest all state - _gaoyu_ - 05-02-2019 (05-02-2019, 10:35 AM)josemendez Wrote: Yes, it's support(at)virtualmethodstudio.com or obi(at)virtualmethodstudio.com I send a mail to support@virtualmethodstudio.com test file in mail |