playMaker

Author Topic: Paddle Ball Direction  (Read 674 times)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Paddle Ball Direction
« on: September 25, 2020, 10:19:25 PM »
Hello Playmakers  :)

I have a paddle (or cube) with a ball that falls down and collides with the cube (or paddle if you prefer), when this happens I add force (impulse) to the ball to send it back up into the air along with a random torque.

What are some ways that I can have the torque value based off of the players X position? If the players position is -0 in X send the ball to the right or if the players position is +0 send the ball to the left.

Im just not sure how to put it together Im sure I'll need Get Position for the player and a x float variable (debug tested and works to get position), Im not sure what other actions would make sense to use?

This is to prevent too many negative or positive random numbers so that the ball stays in bounds and doesn't go off screen after bouncing off of the paddle (cube) a few times.
Have I said how much I love playmaker!!! This is one amazing tool

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Paddle Ball Direction
« Reply #1 on: September 27, 2020, 05:13:42 AM »
Hi.
You could have a empty game object centered and on paddle hit, get the paddle x position and the empty game object x position.

then do a float operator (paddle x - empty game object x)

When result is higher than 0, its in the right side and when less its on the left.
for 0 you should set to go right or left (your choice) not both.
or you could set a center and for example greater than -1 and less than 1 could be centered.

you can even use the float to manipulate the torque as you have now a distance from center value :)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Paddle Ball Direction [SOLVED]
« Reply #2 on: September 29, 2020, 04:22:26 PM »
Hi DJ,

Man you are amazing! This is a nice little trick for sure (I like it a lot), THANK YOU!
Have I said how much I love playmaker!!! This is one amazing tool