Hi! This has been asked a few times here, but I’m still a little unclear on it…it seems like there are a few ways to declare a new Vector2 variable:
public class BallController : MonoBehaviour
{
[SerializeField] PaddleController paddle1;
**// Here, the paddleToBallVector Vector2 is declared like any variable**
** Vector2 paddleToBallVector;**
void Start()
{
paddleToBallVector = transform.position - paddle1.transform.position;
}
void Update()
{
**// Here, the paddlePos Vector2 variable is declared with the new Vector2 syntax**
** Vector2 paddlePos = new Vector2(paddle1.transform.position.x, paddle1.transform.position.y);**
transform.position = paddlePos + paddleToBallVector;
}
}
What’s the difference here? Is it about what you want to eventually do with the vectors? For example, paddleToBallVector is fed other vectors as values, whereas paddlePos is fed separate coordinates for x & y?
Thanks in advance!