About Moving? - 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: About Moving? (/thread-2771.html) |
About Moving? - zero16832 - 27-02-2021 According to the example you provided, I wrote a demo that uses the mouse to move. At first, the demo is normal, but the later movement slowly turns into the opposite direction. Why? if (Input.GetMouseButton(0)) { direction += moveDirection* moveSpeed; softbody.AddForce(direction.normalized * moveSpeed, ForceMode.Acceleration); } RE: About Moving? - josemendez - 27-02-2021 (27-02-2021, 09:15 AM)zero16832 Wrote: According to the example you provided, I wrote a demo that uses the mouse to move. At first, the demo is normal, but the later movement slowly turns into the opposite direction. Why? It’s hard to tell just by looking at that code. However, the code doesn’t make a lot of sense to me: You’re adding moveDirection * moveSpeed to direction, but you’re then normalizing it. This will make direction a vector of unit length, but then you multiply it by moveSpeed a second time. No need to do the first multiplication if you’re normalizing the vector afterwards, as it will be unit length anyways. I don’t see anything that would reverse the movement direction though. Can you post the full code? RE: About Moving? - zero16832 - 27-02-2021 It's normal to use "addforce" in "editor" to move, but in "mobile", it's normal at the beginning, and then "addforce" gradually becomes invalid for the second or third time. Sometimes it moves in the opposite direction, sometimes it doesn't move directly. I make sure that the direction I apply to "softbody" is the same, but I feel affected by an inexplicable reverse force. I found the [font=宋体, monospace]solver.velocities [/font]it would go back to zero automatically? and can i use change [font=宋体, monospace]velocities.x to make the item move?[/font] (27-02-2021, 09:56 AM)josemendez Wrote: It’s hard to tell just by looking at that code. However, the code doesn’t make a lot of sense to me: the code here,i just change some code with the obi demo. [attachment=899]code here RE: About Moving? - josemendez - 28-02-2021 (27-02-2021, 10:17 AM)zero16832 Wrote: It's normal to use "addforce" in "editor" to move, but in "mobile", it's normal at the beginning, and then "addforce" gradually becomes invalid for the second or third time. Sometimes it moves in the opposite direction, sometimes it doesn't move directly. I make sure that the direction I apply to "softbody" is the same, but I feel affected by an inexplicable reverse force. Hi, Just tested your code (commented out the GameManager references/lines, as I don't have that script) and it works fine for me. The softbody always moves in the same direction. What are you using as your referenceFrame? The script moves the softbody in the direction of referenceFrame's axis, so only possible explanation is that the frame is rotating/pointing in some unexpected direction. The original script uses this to make the controls relative to the camera frame. On a side note, this part of the script: Code: for (int i = 0; i < softbody.solverIndices.Length; i++) Looks wrong, you're iterating over solver.velocities, but using the length of the softbody indices array. This will result in incorrect results at best, or an out of bounds access at worst. I think what you want is: Code: for (int i = 0; i < softbody.solverIndices.Length; i++) Quote:I found the [font=宋体, monospace]solver.velocities [/font]it would go back to zero automatically? Your script is not setting velocities at any point, you're just logging their value. It never actually writes back the modified values: Code: // copy the velocity on the x axis into a variable: Since velocities are automatically calculated by the physics engine, they will reach zero eventually in absence of any external modifications. RE: About Moving? - zero16832 - 01-03-2021 YEAH I USE THIS SCRIPT IN WINDOW OR UNITY EDITOR IT WELL,BUT IN ANDROID OR IOS,IT HAVE SOME problem,When click on the screen and then release the click, and click the second time, the direction of movement changes. I don't know what's going on。It felt like there was an inexplicable reverse force RE: About Moving? - the-lander - 01-03-2021 Hey! I'm not the one with this bug! Same problem here: http://obi.virtualmethodstudio.com/forum/thread-2468.html Everything is ok in on PC but on Android the further a softbody goes from the zero point in unity the more it's forced to move there by itself. It's like my softbodies are connected with something with a rubber string. Every new project I've started using different Unity version has this bug. Here are some videos: https://www.youtube.com/watch?v=f1ALZPc1Kfg&feature=youtu.be4 https://drive.google.com/drive/folders/1SQAqHZQ_uDF6j2jKIGxqi-7r3Ke_f6q8?usp=sharing RE: About Moving? - josemendez - 01-03-2021 (01-03-2021, 08:23 AM)the-lander Wrote: Hey! I'm not the one with this bug! Could reproduce this on Android, but not on iOS. I suspect OP's issue and yours are completely unrelated. Will get back once I have more information. RE: About Moving? - josemendez - 01-03-2021 (01-03-2021, 02:17 AM)zero16832 Wrote: YEAH I USE THIS SCRIPT IN WINDOW OR UNITY EDITOR IT WELL,BUT IN ANDROID OR IOS,IT HAVE SOME problem,When click on the screen and then release the click, and click the second time, the direction of movement changes. I don't know what's going on。It felt like there was an inexplicable reverse force I'm still unable to see any differences in behavior when building to iOS/Android. Another user has reported a similar problem (see above), but their project had different circumstances, related to floating point precision issues. Would it be possible to share your project with us so that we can take a look at scene setup and other settings? send it to support(at)virtualmethodstudio.com. RE: About Moving? - zero16832 - 02-03-2021 (01-03-2021, 01:26 PM)josemendez Wrote: I'm still unable to see any differences in behavior when building to iOS/Android. Another user has reported a similar problem (see above), but their project had different circumstances, related to floating point precision issues.The Demo Is send your,thx for your help RE: About Moving? - zero16832 - 02-03-2021 (01-03-2021, 01:26 PM)josemendez Wrote: I'm still unable to see any differences in behavior when building to iOS/Android. Another user has reported a similar problem (see above), but their project had different circumstances, related to floating point precision issues.Have you come back to that problem? |