Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Linking the positions of actors and other objects
#1
Currently, I'm trying to place an empty object in each of the two Obi Rope's approximate centers in the same solver.

Hierarchy is as follows.
Code:
□Obi Solver
  -rope1
  -rope2
□pointObject1
□pointObject2

The following script is pasted on each rope.
Code:
ObiActor actor;
public GameObject pointObject;
int ropeCenterIndex;

void Awake()
{
  actor = this.gameObject.GetComponent<ObiActor>();
  ropeCenterIndex = actor.solverIndices.Length / 2;
}

void Update()
{
  var position = actor.solver.positions[ropeCenterIndex];
  pointObject.transform.position = new Vector3(position.x,
  position.y,
  position.z);
}


For the "public GameObject pointObject" part, I manually put pointObject1 in rope1 and pointObject2 in rope2 from the Inspector.

When this is done, the center of rope2 and pointObject1 will move in tandem, and pointObject2 will not move from its original position, which is a strange state.

How can I get each pointObject to work with the center of each rope?


Sorry for always a beginner question.

Thank you.
Reply


Messages In This Thread
Linking the positions of actors and other objects - by NakanHogeri - 28-02-2021, 02:00 PM