Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Make a player X ball control

Discussion in 'Physics' started by gabrimo, Apr 11, 2020.

  1. gabrimo

    gabrimo

    Joined:
    May 2, 2015
    Posts:
    86
    Hi everyone, I've been trying to build a soccer prototype. My current goal is to make a simple ball control system. Right now, I'm failing to figure out a way to make the ball "attach" to the player, once he touches it. If you already played FIFA or PES you should know what I meant, once you get the ball, it kinda "sticks" in a zone in front of the controlled player, to ensure the possession remains with that player till something else happens with the ball...

    My player is a kinematic rigidbody while my ball is a regular rigidbody. Right now, I already have a FIFA control like for my player working, but once it touches in the ball, it feels too much loose and obviously doesn't follow the player properly once it's movement angle changes. I've been struggle to find a good way to properly link them. Does anybody have some thoughts to help me out?

    Thanks.
     
  2. JamesGamesInc

    JamesGamesInc

    Joined:
    Apr 12, 2020
    Posts:
    3
    A way I have fixed a problem similar to this in the past is to set the ball as a child of the player. The ball will still be free to move but the player will have an influence on it.
     
  3. gabrimo

    gabrimo

    Joined:
    May 2, 2015
    Posts:
    86
    Thanks for the answer. Right now I'm following a different approach purposed by a friend, it involves kinematic equations and ball's isKinematic property. Already tried to make the ball child of player, but this changed the scale of the ball and it seems that this is the expected behaviour for this kind of relationship between game objects. I'll stick with my friend's idea for now, it seems promising...