- Home /
Goalkeeper movement.
I am making a simple soccer penalty shootout game. I am not able to do scripting for goalkeeper. Can anyone help me?
Pretty vague question, what exactly do you want? if you want the goalkeeper to simply move from side to side across the goal then you could use unity's animation editor or Vector3.Lerp().
If you're looking for a character jumping one side or the other and catching the ball with his hands, we're far beyond "simple"
Now i am able to move the goalkeeper but how to reset his position. Whenever goal is scored or if he saves the goal then i want to reset his position to his initial position. How to do that?
Create a vector3 named initialPosition and assign its values to the xyz position you want to return to, then, when you want your goalkeeper to return to initial position say that goalkeeper.transform.position = initialPosition and you're good to go! if you want the goalkeeper to move smoothly back to its initial position then you could use vector3.Lerp().
That didnt work. But i did something else and its working. Thanks for the help though.
Answer by united4life · Nov 23, 2012 at 08:02 PM
Now i am able to move the goalkeeper but how to reset his position. Whenever goal is scored or if he saves the goal then i want to reset his position to his initial position. Ho to do that?
Can you please provide the code how you did that so others can also gain some knowledge regarding that... Thanks in Advance.
Answer by Karsnen_2 · Nov 23, 2012 at 08:35 PM
Have a position near the center of the D box as the default position for the GK.
When the ball enter the your half of the field, create a switch between "Opponent Possession" & "Your Possession".
Lets first talk about "Opponent Possession". Always LookAt the ball. Create a percentage of the ball from you towards the half line.
Depending upon this percentage position the GK towards the ball. Also Calculate the percentage of the ball on the width of the pitch. WIth this percentage, position the GK within the width of the GK area.
When the ball is less than certain distance from the GK, make a run for the ball.
If the ball is less than certain distance (min) from the GK, allow the GK to snatch the ball 8 out of 10 times. (Value of the Player).
Considering the case of "Your Possession", at times when you have to snatch the ball the player actually has to kick the ball.
I hope this helps to start!!!
Your answer
Follow this Question
Related Questions
football script 1 Answer
Football goal script 1 Answer
flick football asset purchased from unity asset store ... 0 Answers
script to add force to the ball in a football game! 1 Answer