Posts: 8
Threads: 3
Joined: Mar 2018
Reputation:
1
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 !
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
20-03-2018, 06:29 PM
(This post was last modified: 20-03-2018, 06:34 PM by josemendez.)
(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 ?
Thanks you !
Hi there,
Use Oni.GetParticlePositions(). See the last bit of:
http://obi.virtualmethodstudio.com/tutor...icles.html
Posts: 8
Threads: 3
Joined: Mar 2018
Reputation:
1
27-03-2018, 08:36 PM
(This post was last modified: 27-03-2018, 08:58 PM by usernameHed.)
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/tutor...icles.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
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-03-2018, 12:22 PM
(This post was last modified: 28-03-2018, 12:22 PM by josemendez.)
(27-03-2018, 08:36 PM)usernameHed Wrote: 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/tutor...icles.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
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();
int lastParticle = dbatch.springIndices[(dbatch.ConstraintCount-1)*2+1];
int firstParticle = dbatch.springIndices[0];
Posts: 8
Threads: 3
Joined: Mar 2018
Reputation:
1
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
Posts: 8
Threads: 3
Joined: Mar 2018
Reputation:
1
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=bcb6bsxZ...e=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/questi...otating-it
Well, hope I don't bother you with all my question. Thanks you !
Here my rope setup:
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(29-03-2018, 11:32 PM)usernameHed Wrote: 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=bcb6bsxZ...e=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/questi...otating-it
Well, hope I don't bother you with all my question. Thanks you !
Here my rope setup:
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)
|