I’m having some troubles following examples I’ve found regarding gluing an object to another’s joint. I understand I should be able to able to access say, a game object attached to the joint. Or even use the joints’ transforms. But I’m not able to find the individual components when I choose a GameObject variable. Only the prefab (not its components) shows up along with the other objects in my scene.
Am I not able to do this with a prefab? I understand I can put it underneath so the joint could be the parent of the object but I’m hoping to be able to use code to control it like this:
var object : GameObject;
if (regularMovement == true) {
regularWalkFunction()
} else {
transform.position = object.jointName.position (what I imagine it might look like)
}
Maybe its just my character models but in yours arent joints GameObjects?
Dont know if this would help you but this is a script I use to “Glue” weapons to my character’s hand joint, its in C#
using UnityEngine;
using System.Collections;
[AddComponentMenu("Rayco's scripts/Weapon placement")]
public class Weaponparenting : MonoBehaviour {
//This is to select the hand Joint
public GameObject HandBone;
//Objects offsets
public Vector3 RotationOffset;
public Vector3 PositionOffset;
// Use this for initialization
void Start () {
transform.localEulerAngles = RotationOffset;
transform.position = HandBone.transform.position;
transform.parent = HandBone.transform;
transform.localPosition = PositionOffset;
}
}