- Home /
problem in changing the throwing angle of a ball,dynamically..!
Hi, I did a game i.e throwing a ball into a target. For the current situation I wrote code like this.
[RequireComponent (typeof(Animation))]
public class Player : MonoBehaviour {
public Vector3 throwDirection = new Vector3( -0.2f, 0.8f, 1.0f );
void Update(){
if (_state == PlayerStateEnum.PreparingToThrow )//if player throwing ball press mouse button, this executes.for that I have different code and that is working fine.
throwBall(throwDirection);
}
public void throwBall(Vector3 v){
basketBall.BallRigidbody.AddRelativeForce( v*(maxThrowForce * _animation[animPrepareThrow.name].normalizedTime));
}
In this A player stands in a boat and that boat moves left to right and right to left(Horizantally Moving) .While the boat along with the player is moving, player has to throw the ball into the target(I arranged 4 bucket kind of containers which are infront of the player at different places and some distance from the player). So as to throw the ball in forward direction only, I fixed the direction of the ball with some dimensions(-0.2,0.8,1) for the parabolic path of the ball. I have to make the ball direction(like giving projectile motion in forward direction) depends on the player throwing point(because the boat position keep changing).I am asked to do the second level of this game.For that I have to get this done. Any suggestions...? Thanx in advance
You might care to format your code so it's readable.
specify what is happening now, and what you would like to have happen. The best way to get help is be as clear as possible.
Your answer
Follow this Question
Related Questions
Spherical legs rolling where that enemy go and not looking 1 Answer
Change direction of ball based on where it hits paddle -- 3d breakout game 0 Answers
Changing the direction of an object using another object. 0 Answers
How to change direction of ball whenever i rotate my camera around it? 1 Answer