playMaker

Author Topic: How to setup player to possess ball, throw ball and have ball knocked away  (Read 617 times)

mr0boe0jangles

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Hi I'm getting up to speed with PlayMaker and wanted some suggestions on how to most simply set up a player being able to move to collect a ball, when collected the ball moves with the player, until another player knocks them, in which case the ball has gravity applied again and the other player (or any that happens to get near enough to the ball next) can pick it up.

Similar to 'Bari Bari Ball'

Would love suggestions on this! Cheers



Rabagast

  • Hero Member
  • *****
  • Posts: 679
    • View Profile
    • Homepage
Hi!

You can parent the ball to the player if you want the ball to move with the player.
If another player knock you down, then you unparent the ball.  :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

mr0boe0jangles

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Thanks for your reply Rabagast.

I followed your advice and set up the parenting, but I'm having a few issues outlined in this screencast:

https://youtu.be/BBcdtpqY0Ds

-Jumping (with add force on player) doesnt seem to move the parented ball with it.
-Throwing the ball in the opossite direction of the player collides it with the player (should i make the player rotate more quickly or instantly?)
-My throwing settup seems overly complex with axis events, I just need to translate the direction of the input to the direction of the throw

Any help would be GREATLY appreciated.

Cheers!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3189
    • View Profile
    • jinxtergames
Hi.
I can't test right now but maybe when parenting you can turn on is kinematic.
as the ball still has its own gravity therefore it does not move together with the player.

This might also get rid of the jiggering from the ball, else i would place another collider.
Make it a little bit bigger than the player and set it as trigger.

Then use a trigger event for the ball.
Then for throwing the ball, first un-parent and disable 'is kinematic' then throw.

mr0boe0jangles

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Thanks djaydino

I now turn on is kinematic when the ball trigger parents it to the player, and off again on throw. The ball now moves better with my player when he jumps up, but if he jumps while running side to side, he doesn't jump as high as though he's running into the ball.

I also made sure I unparent before the add force for the throw.

How do I get the ball to change its location upon pickup so it centers itself in front of my player, rather than the spot at which the trigger collides?

Also how do I add diagonal directions to throw? 'Axis event' only gives me mutually exclusive options. Ideally i'd like the ball to be thrown in exactly the direction of the controller stick, is there a simply way to set force direction according to axis direction?

Thanks!

Rabagast

  • Hero Member
  • *****
  • Posts: 679
    • View Profile
    • Homepage
Quote
How do I get the ball to change its location upon pickup so it centers itself in front of my player, rather than the spot at which the trigger collides?

Maybe you can use Set Position or use an Empty Game Object and place it in the front of the Player and set the position of the ball to that game object.

Quote
Also how do I add diagonal directions to throw? 'Axis event' only gives me mutually exclusive options. Ideally i'd like the ball to be thrown in exactly the direction of the controller stick, is there a simply way to set force direction according to axis direction?

On "Add Force", if you change the space to self, then the object moves the direction it's facing. If you use "Add Force 2D", then you need to use "Add Relative Force 2D".

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

mr0boe0jangles

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Thanks Rabagast,

I'll try to use set position to put the ball at the right spot relative to the player once parented. Would you suggest parenting it to a hand rather than the whole object so it looks like its being held??

Using add force Self - my issue is I want the player to be able to throw the ball in any direction, not only the way he is facing, and up or down (currently my player on rotates in the Y axis), so he is never 'facing' up or down'.

Is there any way to store a vector value and use it for the force direction, rather than just defining up down etc so I can use a joystick/controller?

Added a video showing in more detail my issues.
https://youtu.be/6I17K4HVa-w


Rabagast

  • Hero Member
  • *****
  • Posts: 679
    • View Profile
    • Homepage
Quote
I'll try to use set position to put the ball at the right spot relative to the player once parented. Would you suggest parenting it to a hand rather than the whole object so it looks like its being held??

Hi!
I would use an empty game object which you place it on the hand and when you pick up the ball, you set the ball to the position of this empty game object.

Quote
Using add force Self - my issue is I want the player to be able to throw the ball in any direction, not only the way he is facing, and up or down (currently my player on rotates in the Y axis), so he is never 'facing' up or down'.

I'm not 100 % sure how to do it. Maybe djaydino knows it. He's better than me. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no