So I have 3 objects doing a transform.position type of thing. One object follows the player, mirroring his every move. The camera follows the player, doing the exact thing. Then a rectangle follows the object following the player. The object following the object following the player, is horrible stuttery. And I don't now why.
Here is the script for it.
using UnityEngine;
using System.Collections;
public class Shield : MonoBehaviour
{
GameObject shieldBase;
Transform rotation;
Vector2 shieldPos;
void Awake()
{
shieldBase = GameObject.FindGameObjectWithTag ("Follow");
}
void Update()
{
ShieldMovement ();
}
void ShieldMovement()
{
rotation = shieldBase.transform;
shieldPos = shieldBase.transform.position;
this.transform.rotation = rotation.rotation;
this.transform.position = shieldPos;
}
}
Incredibly simple code. All it needs to do is change it's position, to the other objects' position every frame. Yet it can't seem to do that. The object it needs to follow, is moving perfectly fine. Yet this object can't seem to keep up for some reason.
It has a rigidbody2d with gravity and mass set as low as possible, i've tried using the interpolate, does nothing. I've tried setting to kinematic. I've removed the rigidbody entirely. Still constant stuttering. Even on the build & run version.
I've noticed this problem a lot in unity, objects just not being able to move without irritating stutter.
↧