![]() |
Animating rod rest position - 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: Animating rod rest position (/thread-2905.html) |
RE: Animating rod rest position - Hakazaba - 23-05-2021 The first frame of the simulation starts at the blueprint rest position, which is different from the new torsion position. So theres a jump at the start as they get into position. So i need a way to change that rest position before the simulation starts so the particles start in the position we want. RE: Animating rod rest position - josemendez - 24-05-2021 (23-05-2021, 04:27 AM)Hakazaba Wrote: The first frame of the simulation starts at the blueprint rest position, which is different from the new torsion position. So theres a jump at the start as they get into position. Try subscribing to actor.OnBlueprintLoaded, and updating the rest position there. That will be called immediately after loading the blueprint, and before simulation starts. RE: Animating rod rest position - Hakazaba - 31-05-2021 Im sorry to ask for this, but im not very familiar with events. How would i write a subscription to that event which triggers a function? RE: Animating rod rest position - josemendez - 31-05-2021 (31-05-2021, 06:53 AM)Hakazaba Wrote: Im sorry to ask for this, but im not very familiar with events. How would i write a subscription to that event which triggers a function? Code: //somewhere in your code (Start, Awake, OnEnable...) you subscribe to OnCollision: See: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/events/how-to-subscribe-to-and-unsubscribe-from-events RE: Animating rod rest position - Hakazaba - 01-06-2021 Code: void SetStartPos(object sender, ObiActor.ActorBlueprintCallback e){ rod is an ObiRod Actor RE: Animating rod rest position - josemendez - 01-06-2021 This is because the signature of the SetStartPos function doesn't match the signature of the event delegate. When you subscribe a function to an event, the number and type of the parameters must match. Otherwise, how would the "output" of the event be passed as "input" to your function? declare SetStartPos as: Quote:void SetStartPos(ObiActor actor, ObiActorBlueprint blueprint) RE: Animating rod rest position - Hakazaba - 02-06-2021 Ok, modifying the rest darboux vectors on that event still does not make the simulation start from the position we want. RE: Animating rod rest position - josemendez - 02-06-2021 (02-06-2021, 05:55 AM)Hakazaba Wrote: Ok, modifying the rest darboux vectors on that event still does not make the simulation start from the position we want. Are you modifying the particle positions/orientations as well? the darboux vectors only set a "target" shape, the current shape of the rod is determined by particles. In a regular blueprint, the darboux vectors are calculated from the starting positions/orientations, so both the starting shape and the target shape are the same. RE: Animating rod rest position - Hakazaba - 10-06-2021 Where exactly should i be setting position and orientation? The values i keep finding only have a get RE: Animating rod rest position - josemendez - 10-06-2021 (10-06-2021, 11:38 AM)Hakazaba Wrote: Where exactly should i be setting position and orientation? The values i keep finding only have a get You get/set positions and orientations by reading from/writing to an array. Check the manual: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html for instance, to set the position of the first particle in a solver to zero: Code: solver.positions[0] = Vector3.zero; to get it: Code: var pos = solver.positions[0]; Same for orientations, velocities, mass, radius, etc. All data in Obi is expressed in the solver's local space, the data you get is solver space, and the data you set is expected to be solver space. actor.GetParticlePosition() and GetParticleOrientation() (which I guess are the ones you found) are just helper methods that retrieve world space values for convenience. They're quite slow though, it's best to access the data directly. |