How to desigh a nagetive missile algorithm?

Started by
0 comments, last by Codeka 14 years, 5 months ago
Hey Guys I've written a simple algorithm of missile chasing in 3D space in XNA: public void Update(GameTime gameTime, Vector3 target) { if (Vector3.Distance(Target, Position) != 0.0f) { float time = (float)gameTime.ElapsedGameTime.TotalSeconds; Target = target; //target position Vector3 Distance = Target - Position;//vector between missile and target OffsetDirection = Vector3.Normalize(Distance);//direction vector Vector3 acceleration = OffsetDirection * Force / Mass; //force=400.0f Mass=3.0f Velocity = acceleration * time + Velocity; //Velocity += accerlation * time Position += Velocity * time; Direction = Vector3.Normalize(Velocity); Direction.Normalize(); Right = Vector3.Cross(Direction, Vector3.Forward); Right.Normalize(); Up = Vector3.Cross(Direction, Right); Up.Normalize(); timeCount -= time; Position += Velocity * time; particle.ParticlePositon = Position; particle.Update(gameTime); } else { particle.ParticlePositon = Position; particle.Update(gameTime); } } this is my main thought of the algorithm but anyway I cant get what I real want ! Anybody could tell me why?
Advertisement
You probably want to use a steering behaviour. You'll want the missle to travel with a constant velocity and "turn" towards the target, rather than just applying a constant acceleration towards the target.

This topic is closed to new replies.

Advertisement