Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

mrmohadnan

Member Since 09 Dec 2011
Offline Last Active Today, 11:17 AM
-----

Posts I've Made

In Topic: chasing

21 May 2013 - 04:16 PM

yeah , thaaaanks belfegor , I got it working and now it's moving toward me , now just orient the enemy when he move toward me so that his body.front direction facing me ! can you refine your code a little bit as you do with steering ? 

usry54ec1lm8a1y6g.jpg

Ray enmyRay;

            enmyRay.Position = dwarfChrachterController.Body.Position;

            enmyRay.Direction = Vector3.Normalize(dwarfChrachterController.Body.OrientationMatrix.Forward);
            double distanceX = (double)(cci.CharacterController.Body.Position.X - dwarfChrachterController.Body.Position.X);
            double distanceZ = (double)(cci.CharacterController.Body.Position.Z - dwarfChrachterController.Body.Position.Z);

            Vector3 velocity =(cci.CharacterController.Body.Position- dwarfChrachterController.Body.Position) ;

            if (Math.Sqrt( (distanceX * distanceX) + (distanceZ * distanceZ)) <=500)
            {
                RunController(dwarfAnimatior, dwarfwalk);
                
                Vector3.Normalize(velocity);
                velocity *= 5.0f;

                dwarfChrachterController.HorizontalMotionConstraint.MovementDirection += new Vector2(velocity.X,velocity.Z);

                if (enmyRay.Intersects(cci.CharacterController.Body.CollisionInformation.BoundingBox) <= 50)
                {
                    RunController(dwarfAnimatior, dwarfattak);
                    sound.playAh();
                }
                velocity = cci.CharacterController.Body.Position - dwarfChrachterController.Body.Position;
            }

In Topic: chasing

21 May 2013 - 03:37 PM

...........................


In Topic: chasing

21 May 2013 - 06:54 AM

belfegor , even when I am in the range he move at his position not translated toward me ? ok I will brothers thanks again :)


In Topic: chasing

21 May 2013 - 05:55 AM

Oh again brother belfegor thaaaaaaaaaanks  , I tried this code but the enemy move at his place ( no translation is done ! )not move , what  do think belfegor ? 

 

 double distanceX = (double)(cci.CharacterController.Body.Position.X - dwarfChrachterController.Body.Position.X);
            double distanceZ = (double)(cci.CharacterController.Body.Position.Z - dwarfChrachterController.Body.Position.Z);
            if (Math.Sqrt( (distanceX * distanceX) + (distanceZ * distanceZ)) <=500)
            {
                RunController(dwarfAnimatior, dwarfwalk);

                Vector3 direction = cci.CharacterController.Body.Position - dwarfChrachterController.Body.Position;

                Vector3.Normalize(direction);

                dwarfChrachterController.Body.Position += direction * 5 * gameTime.ElapsedGameTime.Seconds;

                if (enemyRay.Intersects(cci.CharacterController.Body.CollisionInformation.BoundingBox) <= 50)
                {
                    sound.playAh();
                }
            }

In Topic: chasing

21 May 2013 - 04:52 AM

thanks David smile.png , sorry I am assuming 3d of course smile.png  , I have bounding box surrounding my player and also for the enemy , now I can fire a ray to check collision in front of enemy then if I am collide with the ray enemy can attack else enemy can't , but this looks odd and very bad as I must be in front of enemy , so instead I want a zone ( circle ) which is dangerous circle so that when I am inside this circle enemy can attack 

Note : anyone have another strategy pls share with some code if you can smile.png .

David , you said that I can do this by using view angle for each enemy instead , can you post some code if you can taking in mind the ray I can use for each model in the game .
dhk5taecpo6k6mp6g.jpg


PARTNERS