Skip to content

Randomize Ball Velocity #15

@alienboy13

Description

@alienboy13
  • Create a maxSpeed variable in the Ball Object
  • Set the maxSpeed variable in the Start Method
  • Initialize the Ball's Speed as only a positive y component of MaxSpeed
  • In the OnCollision Enter method, create local variables for the x and y components of the Ball's velocity
  • Check what the position of the collider is relative to the ball, checking for up, down, left, and right
  • If the collider is up, invert the y direction and randomize the x
  • if the collider is down, invert the y direction and randomize the x
  • if the collider is to the left, invert the x direction and randomize the y
  • If the collider is to the right, invert the x direction and randomize the y

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions