I am a beginner and trying to recreate Pong.
I made this script for the movement but the object is clipping trough the walls i made.
This probably is because im just changing the transform.
Does anyone have a solution for this?
Script:
using UnityEngine;
public class Movement2 : MonoBehaviour
{
public float movementForce = 0.2f;
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKey(KeyCode.W))
{
transform.position = transform.position + new Vector3(0, movementForce, 0);
}
if (Input.GetKey(KeyCode.S))
{
transform.position = transform.position + new Vector3(0, -movementForce, 0);
}
}
}