playMaker

Author Topic: How to make my character control object move a ball? [SOLVED]  (Read 4665 times)

SpacialPumpkin

  • Playmaker Newbie
  • *
  • Posts: 14
How to make my character control object move a ball? [SOLVED]
« on: August 14, 2013, 12:29:27 AM »
Hi! I am wondering how to get my character that has the character control component to be able to push a ball and make it roll. I gave rigidbody to the ball and it still stays static. Am I supposed to make an apply force action? Or can I just make it react by itself through collision?
« Last Edit: August 25, 2013, 08:52:17 PM by SpacialPumpkin »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make my character control object move a ball?
« Reply #1 on: August 14, 2013, 03:16:08 AM »
Hi,

 if you are using a Character controller, indeed physics doesn't work the same way. and indeed you simply need to look for collisions and apply a force in the direction of the collision.

But maybe in your case you could switch to a full physics character? do you expect a lot of similar interactions in your game?

bye,

Jean

SpacialPumpkin

  • Playmaker Newbie
  • *
  • Posts: 14
Re: How to make my character control object move a ball?
« Reply #2 on: August 14, 2013, 03:52:26 AM »
Hi,

 if you are using a Character controller, indeed physics doesn't work the same way. and indeed you simply need to look for collisions and apply a force in the direction of the collision.

But maybe in your case you could switch to a full physics character? do you expect a lot of similar interactions in your game?

bye,

Jean

I want to make a 3d Soccer game with the collisions of a player being able to move the ball with just moving into it, and being able to kick it. How can I achieve this with an FSM?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make my character control object move a ball?
« Reply #3 on: August 14, 2013, 04:36:26 AM »
Hi,

 here is a starting point. move the character and it will kick the ball automatically.

few points to understand the system:

-- I added a capsule collider, because character controller is a special kind of physics object, so it's needed ( as far as I can tell)

-- the ball is checking for collision event, ONLY coming from the player ( I labelled the player with a "player" tag)

-- I get the velocity of the collision which give me the direction of the kick ( inverted ) so I multiply it with a negative factor to kick it away.

-- I also add an upward force to make the ball go in the air.

Have a go, if you have questions, don't hesitate.

bye,

Jean

SpacialPumpkin

  • Playmaker Newbie
  • *
  • Posts: 14
Re: How to make my character control object move a ball?
« Reply #4 on: August 14, 2013, 04:55:09 AM »
Hi,

 here is a starting point. move the character and it will kick the ball automatically.

few points to understand the system:

-- I added a capsule collider, because character controller is a special kind of physics object, so it's needed ( as far as I can tell)

-- the ball is checking for collision event, ONLY coming from the player ( I labelled the player with a "player" tag)

-- I get the velocity of the collision which give me the direction of the kick ( inverted ) so I multiply it with a negative factor to kick it away.

-- I also add an upward force to make the ball go in the air.

Have a go, if you have questions, don't hesitate.

bye,

Jean

Wow! Thank you so much!! I have a question though...when I try to add a capsule collider on to my object, it wants to replace my character controller with it. How did you get your object to have both?

EDIT: Woops! Sorry, didn't see the other "Add" option!
« Last Edit: August 14, 2013, 04:59:40 AM by SpacialPumpkin »

SpacialPumpkin

  • Playmaker Newbie
  • *
  • Posts: 14
Re: How to make my character control object move a ball?
« Reply #5 on: August 22, 2013, 02:34:21 PM »
Hi again. I got everything working, but the only problem is my soccer ball has a lag when it first is touched by my player before it moves. After the first contact with the player and about 2 seconds, it moves around fine. I have tried everything to fix this and I cannot figure it out. Does anyone have any idea why this is happening?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make my character control object move a ball?
« Reply #6 on: August 24, 2013, 07:51:06 AM »
Hi,

 Does the lag happen in my package as well?

bye,

Jean

SpacialPumpkin

  • Playmaker Newbie
  • *
  • Posts: 14
Re: How to make my character control object move a ball?
« Reply #7 on: August 25, 2013, 03:22:27 AM »
Hi,

 Does the lag happen in my package as well?

bye,

Jean

No, yours is perfect. I just cannot figure out what I did with mine. I followed yours and mine just ended up like this somehow :(

EDIT: Someone pointed out to me that I needed a rigidbody on my player, not just my ball, with a mass of 8. This completely fixed the problem! :)
« Last Edit: September 08, 2013, 10:19:21 PM by SpacialPumpkin »