Quantcast
Channel: Questions in topic: "dynamically"
Viewing all articles
Browse latest Browse all 152

problem in changing the throwing angle of a ball,dynamically..!

$
0
0
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

Viewing all articles
Browse latest Browse all 152

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>