I have an Imported mesh, cylinder and 3 capsules. the last 4 items have configurable joints, and make up a rope I’m going to use for a grapple hook The last capsule is the object the script is on. . I need to Instantiate more hooks as the player holds down a button and the rope gets longer. To do that, I’m going to instantiate new capsules, giving the impression of longer rope. For now it just comes out right away, for easier testing purposes.
However when I instantiate it, it goes to a crazy far away spot, and I have no idea why. It happened with another object in a similar way last post I put on here and no one on here could figure out why.
Basically I want to instantiate it to to the GameObject the script is on’s position, with a bit more on the y axis, but it’s in a completely far off spot. We’re talking nearly around as far out as the environment goes. Why isn’t the Vectior3 “Gop” being read as the gameObject’s position?
if TL;DR, why is the Vector Gop not containing the same coordinates as my gameObject? Something similar happens with transform.Up as well.
HingeJoint hingejoint;
public GameObject oneChain;
public GameObject onechainclone;
public Rigidbody OneRigid;
public Rigidbody clonerb;
ConfigurableJoint lol;
public float newJ;
// Use this for initialization
void Start () {
newJ = 1;
hingejoint = gameObject.GetComponent<HingeJoint>();
}
// Update is called once per frame
void Update()
{
newJ = newJ + 1;
if (newJ == 15)
{
Vector3 Gop = new Vector3(gameObject.transform.localPosition.x, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z);
Vector3 lulz = new Vector3(hingejoint.anchor.x, hingejoint.anchor.y, hingejoint.anchor.z);
onechainclone = Instantiate(oneChain, Gop, transform.rotation) as GameObject;
clonerb = onechainclone.GetComponent<Rigidbody>();
onechainclone.transform.localScale = new Vector3(5, 15, 5);
hingejoint.connectedBody = clonerb;
hingejoint.autoConfigureConnectedAnchor = true;
}
}
}