Help Constrain particles on axis - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Help Constrain particles on axis (/thread-924.html) Pages:
1
2
|
RE: Constrain particles on axis - Richard - 22-02-2019 (22-02-2019, 03:01 PM)josemendez Wrote: Using Vector3.Project or Vector.ProjectOnPlane to constraint a velocity vector, I think is trivial.Does transform include meaning of velocity vector? RE: Constrain particles on axis - josemendez - 22-02-2019 (22-02-2019, 03:31 PM)Richard Wrote: Does transform include meaning of velocity vector? Sorry, but I don't fully understand the question. If you're asking whether a transform has a "velocity" property, no it doesn't. A transform is composed of position, rotation and scale. No velocity or other physical attributes whatsoever. Particles in Obi are not transforms either. They're just an index, that can be used to access their position, velocity, mass, etc. See: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html RE: Constrain particles on axis - Richard - 22-02-2019 (22-02-2019, 03:46 PM)josemendez Wrote: Sorry, but I don't fully understand the question. I had to explain more. In the link you showed me has a code void Slide(Transform target, Vector3 railDirection) although the template is public static Vector3 Project(Vector3 vector, Vector3 onNormal);, and you said "Using Vector3.Project or Vector.ProjectOnPlane to constraint a velocity vector". So I asked that question. I try to move some particle by transform, too. Obi's velocity is moved by vector? RE: Constrain particles on axis - josemendez - 22-02-2019 (22-02-2019, 03:55 PM)Richard Wrote: I had to explain more. In the link you showed me has a code void Slide(Transform target, Vector3 railDirection) although the template is public static Vector3 Project(Vector3 vector, Vector3 onNormal);, and you said "Using Vector3.Project or Vector.ProjectOnPlane to constraint a velocity vector". So I asked that question. You cannot move a particle by changing its transform, because it does not have one. Particles are moved by changing their velocity, which is a vector. Like this: Code: // solver index of the first particle in the actor. The code in the link is just an example. They have defined a custom function Slide(Transform target, Vector3 railDirection), which calculates a heading vector by subtracting the gameObject's position (transform.position) from the the target transform (passed by parameter), hence: Code: Vector3 heading = target.position - transform.position; Then they use Vector3.Project() to project this heading vector onto the rail direction: Code: Vector3 force = Vector3.Project(heading, railDirection); And feed that as a force to the rigidbody component: Code: GetComponent<Rigidbody>().AddForce(force); This is a extremely basic script. Please learn how programming works before attempting to do more complex stuff. I will not answer any more questions unless they're directly related to Obi. For C#/Unity related questions, please use this forum instead: https://forum.unity.com/forums/scripting.12/ RE: Constrain particles on axis - Richard - 22-02-2019 (22-02-2019, 06:44 PM)josemendez Wrote: You cannot move a particle by changing its transform, because it does not have one. Particles are moved by changing their velocity, which is a vector. Like this: Sorry, I should do so. |