I have a 2d animation which is 3 sprites long. It works fine on its own.
As I have moved forward, I added code to update the transform and now the animation is flickering.
This code is attached to the object.
I am running this on Windows 10
Unity version 2019.4.2f1 Personal
The issue happens both in game preview and in the Scene manager.
void Update()
{
float mousePos = Input.mousePosition.x / Screen.width * screenWidthInUnits;
Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y);
transform.position = paddlePos;
}
}
If I comment out the last line like this the flickering goes away
void Update()
{
float mousePos = Input.mousePosition.x / Screen.width * screenWidthInUnits;
Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y);
//transform.position = paddlePos;
}
I have attempted to google this with no luck.
If anyone wishes to try to run the code themselves I have it listed here on github as I am just using this as a way to learn Unity
https://github.com/StevenDStanton/Block-Breaker
raarc
2
try doing
Vector3 paddlePos = new Vector3(transform.position.x, transform.position.y,transform.position.z);
transform.position = paddlePos;
1 Like
Thank you,
Converting it to the Vector3 solves the issue. I appreciate the help!
1 Like