(09-05-2019, 04:02 PM)josemendez Wrote: Hi there,
Tested in the Crane sample scene, but can't reproduce anything strange. Programmatically parenting to a pinned object works just fine for me. Can you share the code you're using to parent the second object?
Thanks Jose,
Here's the code:
Code:
private void OnTriggerStay(Collider other)
{
print("Got a collision with " + other.gameObject.name);
if (other.gameObject.tag == "LiftPoint")
{
if (Vector3.Distance(transform.position, other.gameObject.transform.position) < connectDistance)
{
print("Got one! " + other.gameObject.name + " is touching " + this);
if (remainingConnectTime > 0)
{
// Countdown remaining time
remainingConnectTime -= Time.deltaTime;
print ("Counting down! " + remainingConnectTime);
}
else
{
print("Connecting!");
// Connect, disable attachpoint, reset timer
remainingConnectTime = connectTime;
other.gameObject.transform.parent.parent = this.transform.Find("LoadAnchor");
other.gameObject.SetActive(false);
}
}
else
{
print("Resetting to " + connectTime + " :-(");
remainingConnectTime = connectTime;
}
}
}
All it's doing is counting down 3 seconds if the hook is inside the attachpoint, then setting the attachpoint's parent's parent to be the anchor of the hook and disabling the attachpoint.
(09-05-2019, 04:20 PM)nigelkennington Wrote: Thanks Jose,
Here's the code:
...
All it's doing is counting down 3 seconds if the hook is inside the attachpoint, then setting the attachpoint's parent's parent to be the anchor of the hook and disabling the attachpoint.
I've taken the rigidbody off the child object and that seems to have fixed it.
Thanks for trying to help though!