Realistic Soccer Ball Dribbling?
Hey Folks! iam currently working on a soccer game and the dribbling looks like this at the moment: link: dribbling v1.gif
void OnTriggerEnter(Collider collision)
{
ControllingFeet = collision.transform;
}
void FixedUpdate()
{
bool isControlled = ControllingFeet != null;
if (isControlled)
{
Vector3 targetPos = ControllingFeet.transform.position;
GetComponent<Rigidbody>().MovePosition(targetPos);
}
}
which actually just mean that, when the ball enters the trigger (which is in front of the character) it transfers the position of the collider (ControllingFeet) to the Ball.
i tried to copy the transform position of the Feet to the collider which is controlling then the ball like this:
using UnityEngine;
using System.Collections;
public class Copyposition : MonoBehaviour
{
public Transform itsTarget;
void Update ()
{
transform.position = new Vector3(itsTarget.position.x, 0 ,itsTarget.position.z);
}
}
but that looks stupid - and not natural at all as you can see in the second half of the gif.
after that i tried to delay the movement of the ControllingFeet like this:
transform.position = new Vector3(itsTarget.position.x+0.8f, 0 ,itsTarget.position.z);
and it comes a tiny bit closer to what i want to achieve. but only works on the X axis ( move to the right) and looks like this:
is somebody here having a idea how i can make the ball movemnt more natural?
Answer by Multitudes22 · May 10, 2016 at 12:24 PM
You could always try using that delay code for both directions, based on which way the character is moving. I feel like the answer is just more math.
i am kinda stuck how to apply the delay for both directions. how could i do this? :)
Your answer
Follow this Question
Related Questions
Counteracting rigidbody velocity using AddForce? 0 Answers
How to make rigidbody not effect movement while still using it for collisions? 0 Answers
Player going through walls 1 Answer
Move Player With Moving Vehicle 1 Answer
Player (RigidBody) jitters when colliding with object and jumping. 0 Answers