- Home /
Making the ball be in front of me
Hi! I'm on a soccer project. I want to get to ball in front of the controlling player, I'm simply using this code
transform.position = controllingPlayer.transform.position+(sahip.transform.forward*4);
that makes the ball in front of me, but it makes the ball ignore the gravity. How can I make this, without affecting rigidbody?
Comment
Answer by RLin · Aug 13, 2015 at 08:24 PM
Use a raycast that checks if the ball is grounded:
if(Physics.Raycast(ball.position,Vector3.down,ballRadius){
//do your movement
}else{
//don't do ball movement
}
Thanks for answering. But when it begins movement,it gets up again.
Your answer