So im making this Unity game where i have a gameobject that im moving and rotation during the game, the thing is the pivot point doesnt stick to the object. It rotates just fine on the spot when the game begins but when it has been moved the the pivotpoint didnt follow and its still rotation around its start location. Im using an "extra" gameobject to get the pivotpoint in the right spot in the first place, this extra object is attached to the first object tho so it SHOULD follow it around.
Any ideas what could be the cause/solution to this? Im pulling out my hair here been moving stuff around all night >.<
Here is the very basic code for the rotating, doubt thats it though.
public float speed = 1f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey(KeyCode.W)) // Gå fremad
{
transform.position -= new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);
}
if (Input.GetKey(KeyCode.S)) // Gå baglæns
{
transform.position += new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);
}
if (Input.GetKey(KeyCode.Q)) // Strafe mod venstre
{
transform.position -= new Vector3 (0.0f, 0.0f, speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.E)) // Strafe mod højre
{
transform.position += new Vector3 (0.0f, 0.0f, speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D)) // Drej mod venstre
{
transform.RotateAround (Vector3.zero, Vector3.up, 20 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A)) // Drej mod højre
{
transform.RotateAround (Vector3.zero, Vector3.up, -20 * Time.deltaTime);
}