Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Get position of particle by script
#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 ?

[Image: HCurkjOViJK_rope.png]

Thanks you !
Reply
#2
(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 ?

[Image: HCurkjOViJK_rope.png]

Thanks you !

Hi there,

Use Oni.GetParticlePositions(). See the last bit of:
http://obi.virtualmethodstudio.com/tutor...icles.html
Reply
#3
After a few Failure, i come back to you...
[Image: HCBtlWcdPbl_Sans-titre.png]
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... 
[Image: HCBt4df0Tml_Capture2.PNG]
[Image: HCBt45qdsql_Capture.PNG]

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
Reply
#4
(27-03-2018, 08:36 PM)usernameHed Wrote: After a few Failure, i come back to you...
[Image: HCBtlWcdPbl_Sans-titre.png]
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... 
[Image: HCBt4df0Tml_Capture2.PNG]
[Image: HCBt45qdsql_Capture.PNG]

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];
Reply
#5
OOh yes !! you saved my day Sonrisa

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 Sonrisa
Reply
#6
Hello ! it's me again, sorry to bother you Triste
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 Sonrisa


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:
[Image: HCDwF3TcwYl_Capture2.PNG]

[Image: HCDwENGYhEl_Capture.PNG]
Reply
#7
(29-03-2018, 11:32 PM)usernameHed Wrote: Hello ! it's me again, sorry to bother you Triste
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 Sonrisa


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:
[Image: HCDwF3TcwYl_Capture2.PNG]

[Image: HCDwENGYhEl_Capture.PNG]

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 Sonrisa.

Also, reducing the physics timestep will also help a lot (ProjectSettings->Time->fixed timestep)
Reply