How do they do soccer animations interactions with the ball?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How do they do soccer animations interactions with the ball?



How do they animations that require interactions with other objects? Like dribble in a soccer game. I mean to be realistic, we need to apply a small force to the ball when collides with one of the feet and then again and again, but what about turning animations? Let’s say we turn backwards, then we need an animation with the ball I think. We cannot think the ball is separate from this animation in that case I suppose. Is there a way to combine these things or a strategy? Thanks in advance.



UPDATE:
I did something for dribbling the ball according to suggestions of @Programmer in the comments.



I use models and animations from Mixamo.



I check the distance to the ball in an update. If it is close enough to activate the dribble animation and IK.


void Update()

if (Vector3.Distance(transform.position, BallTest.instance.transform.position) < 1.5f)

animator.CrossFade("Dribble", 0.5f);
useIK = true;

else

useIK = false;




I attach a collider to the controlling feet and if "useIK" is on then apply a force to the ball.


void OnTriggerEnter(Collider other)

if (other.gameObject.tag == "Ball")

if (!useIK)

return;


BallTest.instance.rigidbody.velocity = Vector3.zero;
BallTest.instance.rigidbody.velocity = ballControlPoint.transform.forward.normalized * 7f;

useIK = false;




Finally, OnAnimatorIK, when the "useIK" is active then set the position of IK to the ball. Create a curve "DribbleKick" in dribble animation to set the IK weight. If "useIK" is false then lerp back to zero.


float t = 0;
float currentTime = 0;
float timeToMove = 0;

void OnAnimatorIK()

if (useIK)

t = animator.GetFloat("DribbleKick");

animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, animator.GetFloat("DribbleKick"));
animator.SetIKPosition(AvatarIKGoal.RightFoot, BallTest.instance.transform.position);

currentTime = 0;
timeToMove += Time.deltaTime;

else if( t != 0)

t = Mathf.Lerp(t, 0, currentTime / timeToMove);

animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, t);
animator.SetIKPosition(AvatarIKGoal.RightFoot, BallTest.instance.transform.position);

currentTime += Time.deltaTime;

if (currentTime >= timeToMove)

currentTime = 0;
timeToMove = 0;
t = 0;





The result is:
https://media.giphy.com/media/fxOeuGQWQzsi9BdD5f/giphy.gif



It still not good but I think for now it is OK.





That requires procedural animation on the character + manual physics simulation on the ball with Physics.Simulate. You need to thoroughly understand both of the things I mentioned about before you can do this.
– Programmer
Aug 6 at 13:53


Physics.Simulate





Can you explain a little bit more? Is manual simulation used for predict future ball position or something else? How they use procedural animation? They use some IK to control the leg of the character and override the animation? I know my knowledge is not enough right now, but if you explain more I will be appreciated. Thanks @Programmer
– ozturk.brk
Aug 10 at 11:17





You didn't get answer because this is a complicated subject. Look into Inverse Kinematics which can be used to grab an object. You can use that to get the ball to your feet when the ball is near then play ball animation
– Programmer
Aug 10 at 15:30





@Programmer Sorry for being a headache. I updated the question according to your suggestions. What do you think of it? Thanks again.
– ozturk.brk
Aug 12 at 9:34









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered