Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmrmohadnan

Posted 21 May 2013 - 04:47 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;
            }

#3mrmohadnan

Posted 21 May 2013 - 04:28 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 ? 

 

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;
            }

#2mrmohadnan

Posted 21 May 2013 - 04:17 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 !

 

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;
            }

#1mrmohadnan

Posted 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 !


PARTNERS