- Home /
Child sprite jittering/vibrating when parent is moving and child is actively rotating (With video)
Video: https://www.youtube.com/watch?v=5fBnwgDycwI If you look at the rotation in the inspector u can see the value change even tho, it theoretically should be constant when movement direction is constant and mouse pos is constant
Here are the scripts that affect this
private void update()
{
moveDelta = new Vector3(movementInput.x, movementInput.y, 0).normalized;
}
private void FixedUpdate()
{
rb.velocity = moveDelta * moveSpeed;
}
public class LookAtMouse : MonoBehaviour
{
private InputHandler inputHandler;
private float angle;
void Start()
{
inputHandler = GetComponentInParent<InputHandler>();
}
private void Update()
{
Vector2 weaponDirection = (inputHandler.mouseWorldPos - transform.position).normalized;
angle = Mathf.Atan2(weaponDirection.y, weaponDirection.x) * Mathf.Rad2Deg;
transform.eulerAngles = new Vector3(0, 0, angle);
}
}
private void OnGUI()
{
mousePos = Mouse.current.position.ReadValue();
//Camera.main.nearClipPlane;
mouseWorldPos = mainCamera.ScreenToWorldPoint(mousePos);
mouseWorldPos.z = 0;
}
Right now I was using OnGUI() just to see if it helped, it didn't. I have tried all kinds of combinations of update, lateudpate ,fixedupdate. I changed script execution order but I can't get it to work
Any ideas or solutions would be greatly appriciated!
Answer by Boogiew · Apr 18 at 07:49 PM
I found the problem, the culprit was The Pixel perfect Camera component, apparently, it makes any moving rotated sprite shake/vibrate. as i didn't really utelize it, I opted just to not use it for now
Can i make this resolved?