22-02-2019, 09:38 AM
Can I constrain particles on x, y or z axis?
Help Constrain particles on axis
|
22-02-2019, 09:38 AM
Can I constrain particles on x, y or z axis?
22-02-2019, 10:37 AM
(22-02-2019, 09:38 AM)Richard Wrote: Can I constrain particles on x, y or z axis? Yes, simply project their position/velocity to the desired axis, using Vector3.Project. https://docs.unity3d.com/ScriptReference...oject.html (22-02-2019, 10:37 AM)josemendez Wrote: Yes, simply project their position/velocity to the desired axis, using Vector3.Project. Sorry, but I could not realize well. The reference states how to change the direction, not to constrain. Or is there another way?
22-02-2019, 11:27 AM
(This post was last modified: 22-02-2019, 11:29 AM by josemendez.)
(22-02-2019, 11:08 AM)Richard Wrote: Sorry, but I could not realize well. The reference states how to change the direction, not to constrain. Or is there another way? Constraining an object so that it moves in a certain direction is equivalent to projecting its velocity vector to that direction, which you can do using that function. In the link I provided, there's an example that constrains a rail-mounted gun so that it only moves along the rail direction. You can do the same for particles, so that they only move in a given axis. (22-02-2019, 11:27 AM)josemendez Wrote: Constraining an object so that it moves in a certain direction is equivalent to projecting its velocity vector to that direction, which you can do using that function. Why the document combine transform and vector like (Transform target, Vector3 railDirection)? I cannot add rigidbody to particles so that I add constrain on axis?
22-02-2019, 12:57 PM
(This post was last modified: 22-02-2019, 01:01 PM by josemendez.)
(22-02-2019, 12:22 PM)Richard Wrote: Why the document combine transform and vector like (Transform target, Vector3 railDirection)? Hi, That's simply a function with two input parameters. You should read more on how C# and programming in general works, as these are very basic issues. You don't need to add a rigidbody component to particles, they already have a velocity. In fact you could not add a component to them even if you wanted, as they are not GameObjects. You just need to use Vector3.Project on their velocity, that's it. (22-02-2019, 12:57 PM)josemendez Wrote: Hi,Hello. That is a hard problem for me. Although the template is public static Vector3 Project(Vector3 vector, Vector3 onNormal);, transform is applied in the case. In case of public static Vector3 Project(Vector3 vector, Vector3 onNormal);, Vector3 vector means actual movement of particle (with nothing processing) and Vector3 onNormal means direction I want them to move ( if I constrain on y and z axis, vector3 (0, 1, 1)), and then Vector3 Project is how I would like them to move?
22-02-2019, 02:02 PM
(This post was last modified: 22-02-2019, 02:04 PM by josemendez.)
(22-02-2019, 01:22 PM)Richard Wrote: Hello. That's why you should read more on the subject (Unity, C# and basic vector algebra) before attempting to use advanced physics simulations. The problem itself is trivial, you just don't have enough knowledge to tackle it yet. Asking others to solve it for you is not going to help you in the long run, at all. (22-02-2019, 01:22 PM)Richard Wrote: In case of public static Vector3 Project(Vector3 vector, Vector3 onNormal);, Vector3 vector means actual movement of particle (with nothing processing) and Vector3 onNormal means direction I want them to move. Yes, the "vector" variable should be the vector you want to project, in this case the particle's velocity. "onNormal" should be the vector you want to project it onto, in your case the axis. (22-02-2019, 01:22 PM)Richard Wrote: if I constrain on y and z axis, vector3 (0, 1, 1)), and then Vector3 Project is how I would like them to move? I think you're mixing up vectors and planes. Constraining something to move on both Y and Z (or X and Z, Z and Y) is done by projecting to a plane, not a vector. By projecting velocity to a vector you essentially get rid of all movement except along that vector. So by projecting to (0,1,1), you're making particles move only along the (0,1,1) vector, which is a diagonal line crossing the YZ plane. To allow a particle to move only in the YZ plane, you'd have to use Vector3.ProjectOnPlane. You'd then pass (1,0,0) as the plane normal. https://docs.unity3d.com/ScriptReference...Plane.html
22-02-2019, 02:49 PM
(22-02-2019, 02:02 PM)josemendez Wrote: That's why you should read more on the subject (Unity, C# and basic vector algebra) before attempting to use advanced physics simulations. The problem itself is trivial, you just don't have enough knowledge to tackle it yet. Asking others to solve it for you is not going to help you in the long run, at all.The trivial c# problem you think is method? And constrain on YZ plane means particle move on the plane, is it OK?
22-02-2019, 03:01 PM
(22-02-2019, 02:49 PM)Richard Wrote: The trivial c# problem you think is method? And constrain on YZ plane means particle move on the plane, is it OK? Using Vector3.Project or Vector.ProjectOnPlane to constraint a velocity vector, I think is trivial. Yes, by constraining to YZ plane I mean the particles can only move on that plane. |
« Next Oldest | Next Newest »
|