Help Get position of particle by script - 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 Get position of particle by script (/thread-497.html) |
Get position of particle by script - usernameHed - 20-03-2018 Hello, I have a Rope, and I have the position of the player attached at the end of the rope. I want to have get the position of the first, and second particle in the world (x,y,z), how do I do ? Thanks you ! RE: Get position of particle by script - josemendez - 20-03-2018 (20-03-2018, 06:10 PM)usernameHed Wrote: Hello, I have a Rope, and I have the position of the player attached at the end of the rope. I want to have get the position of the first, and second particle in the world (x,y,z), how do I do ? Hi there, Use Oni.GetParticlePositions(). See the last bit of: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html RE: Get position of particle by script - usernameHed - 27-03-2018 After a few Failure, i come back to you... I do not need math, I can handle it, but i need to find the right particle position depending of the rope, and i fail to find it... I try your link http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html I manage to find the first particle: actor.GetParticlePosition(0) OK, but now, i want the "last": actor.GetParticlePosition(actor.velocities.Length - 1) But it doesn't work... Maybe this is caused by the 100 pooled particle ? so I do that: actor.GetParticlePosition(actor.velocities.Length - 1 - rope.PooledParticle) But no way... I think i'm close, but i didn't manage to find THE point who are always close to the other extremity of the rope. I you can help me i'm stuck on it since last time Thanks RE: Get position of particle by script - josemendez - 28-03-2018 (27-03-2018, 08:36 PM)usernameHed Wrote: After a few Failure, i come back to you... If you are using ObiRopeCursor to change rope length at runtime, keep in mind that new particles will be added mid-rope (or wherever the cursor is). This will cause the last particle in the particles array to be the most recently added one, not necessarily at the end of the rope. To get the first and last particles in the rope (topologically speaking), you can use distance constraints to find them easily: Code: ObiDistanceConstraintBatch dbatch = rope.DistanceConstraints.GetFirstBatch(); RE: Get position of particle by script - usernameHed - 29-03-2018 OOh yes !! you saved my day I would like to thanks you for your work. AND your help. I will recommend your work to my student classmate, and on asset store RE: Get position of particle by script - usernameHed - 29-03-2018 Hello ! it's me again, sorry to bother you I'm staying in this topic, because this is linked to my previous question. Here a video of my current setup: https://www.youtube.com/watch?v=bcb6bsxZRrs&feature=youtu.be I have 2 player, with rigidbody. In the video, for testing, the red player is kinematic, and I can move the blue player. As you see, I get the particle position to get the vector direction, and then with a cross product, I can know in which direction to go when pressing left / right. Great But now, a problem: from know, the rope where fine, but in this particulare move: the rope is too stretchy. here is my question: My Rope is perfect right now, but whenever in my game I am in a certain mode (like in the video), I want to setup my rope as "non stretchy at all". I want to be able to rotate around my player, but keep always the same distance. (MayBe setup a ConfigurableJoint with the right setup ?) I ask a question in GameDeveloppment where I ask how to setup a ConfigurableJoint like that: https://gamedev.stackexchange.com/questions/156963/configurable-joint-how-to-create-a-fixedjoint-and-rotating-it Well, hope I don't bother you with all my question. Thanks you ! Here my rope setup: RE: Get position of particle by script - josemendez - 30-03-2018 (29-03-2018, 11:32 PM)usernameHed Wrote: Hello ! it's me again, sorry to bother you Completely non stretchy rope is not possible to achieve, that would require infinite amount of iterations. But changing the distance constraints update mode from parallel to sequential will help you a great deal . Also, reducing the physics timestep will also help a lot (ProjectSettings->Time->fixed timestep) |