Here’s the thing, when I start the game and the ball drops it touches and collides with the paddles yet when I try to flip the paddles and push the ball it sorta fazes threw, here’s the code for the flippers, and any help is appreciated :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RightPaddleScript : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.D))
{
transform.Rotate(0f, 0f, -22f);
}
if (Input.GetKeyUp(KeyCode.D))
{
transform.Rotate(0f, 0f, 22f);
}
}
}
Have you attached an appropriate rigidbody and collider to your paddles and ball? If yes, maybe you should try adding a physics material with a bounce to your ball.
You should not modify the Transform when using physics. The only things that should move in physics are Rigidbody(2D) so use their API because it’s their job to update the Transform with their poses; not the other way around. Also, modifying the Transform does not update the physics immediately, it only happens when the simulation runs which by default is the fixed-update. By modifying the Transform you’re going to cause an instant chang in position/rotation when the simulation runs i.e. teleport from one pose to another without moving through the space inbetween.
For flippers which don’t want to respond to forces from collision, use a Kinematic Rigidbody(2D) and call MoveRotation on it. Again, physics doesn’t run per-frame unless you’ve set that up so you should do that during the FixedUpdate or run physics per-frame.
Hi,
I have no idea of what fazes threw means, but moving the paddles at 22 degrees/frame is a seriously high speed. Have you thought of making them move at a lower speed?