Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Add constraint following hook example
#2
Hi there,

Asumiría, por el nombre de tu script ("Temporal/LianasTest"), que eres hispanohablante. Yo soy español, si prefieres podemos hablar por correo en español Sonrisa. Te contesto a este post en inglés:

Blueprints behave like prefabs indeed: they're used to instantiate particle/constraint data into the scene (in the form of a ObiActor, such as a rope), but the original blueprint data is not tied to existing instances. If you modify blueprint data, existing actors won't be affected. Only actors that you create from them on will "inherit" the changes made on the blueprint. So your second attempt is the correct one.

There's 2 important things missing from your script:
- You're not activating the constraints.
- You're not telling the actor to rebuild constraint batches. (Obi 5.6 and up only)

The correct code (in Obi 5.6) would be:

Code:
var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;

//remove all existing pin constraint batches
pinConstraints.Clear();

// create a new batch and add one constraint to it:
var batch = new ObiPinConstraintsBatch();
batch.AddConstraint(rope.solverIndices[0], m_Player, transform.localPosition, Quaternion.identity); //<--- notice that we're using the solverIndices array

// activate that one constraint:
batch.activeConstraintCount = 1;

// add the batch:
pinConstraints.AddBatch(batch);

// notify the actor that constraints need to be rebuilt in the solver:
rope.SetConstraintsDirty(Oni.ConstraintType.Pin);


Also, check that pin constraints are globally enabled in your solver.
Reply


Messages In This Thread
RE: Add constraint following hook example - by josemendez - 21-10-2020, 08:45 AM