So I think I’ve done the exact same but for some reason my code doesn’t make the ball follow the paddle, it just changes where the ball is at the start and then nothing happens. But when I copy the codes in the lecture it works.
Here are my codes what did I do wrong and what causes that problem ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ball : MonoBehaviour
{
// configuration
[SerializeField] Paddle paddle1;
// state
Vector2 paddleToBallVector;
// Start is called before the first frame update
void Start()
{
paddleToBallVector = transform.position - paddle1.transform.position;
}
// Update is called once per frame
void Update()
{
Vector2 paddlePos = new Vector2(paddle1.transform.position.x, paddle1.transform.position.y);
transform.position = paddlePos = paddleToBallVector;
}
}
Are my codes not respecting me because I am not experienced