Hi,
I'm developing a breakout's like game and I've a very simple problem with physics.
Here's my code:
-
public void FixedUpdate()
-
{
-
if (ballInPlay)
-
{
-
// Ball movement
-
transform.position += direction * speed * Time.fixedDeltaTime;
-
}
-
}
-
-
public virtual void OnCollisionEnter2D(Collision2D collision)
-
{
-
// Change direction after collision
-
if (ballInPlay)
-
{
-
GameObject go = collision.gameObject;
-
direction = Vector2.Reflect(direction, collision.GetContact(0).normal);
-
}
-
}
Basically the ball's movement is erratic, every time the ball hits something, it change its acceleration but direction is right. I don'use any physic material because I need some custom behavior.
Thank you for replying.