Jump to content
  • Advertisement

Andrew Blem

Member
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

139 Neutral

About Andrew Blem

  • Rank
    Member
  1. Well when i implemented my FSM i experienced performance issues because some functions where being called ever frame so i had to create another "CustomUpdate"  function that I can control its execution frequency like tell it to execute 10 times every second which increased my performance. Since I want to convert that same FSM to a behavior tree I thought I might experience some performance issue. I want to use it to create an A.I for a soccer game so that I can ask someone to play the game and see if they can see any difference between a team implementing the behavior tree or the FSM. The thing now is I want to implement my own tree and a heads up on how I can do it will be appreciated.
  2. I have a state machine I want to implement as a behavior tree. I now have an understanding of how they work but I cant seem to find an implementation of a behavior tree. I have implemented a simple one using a plug-in called Behavior Machine but the problem I have with it is I feel like it limits me just as it did when I used it for making my FSM until i implemented my own. The other problem I have is it is difficult to implement my own nodes and control which part executes(optimization). Any idea on where I can find a good tutorial on how I can do this preferably on Unity and in C# or in java. Or where I can find a good library with proper documentation because the one I found on Github or other sights are buggy or its just some classes with no documentation. Your help will be greatly appreciated.
  3. i have been working on a soccer game for the past several months. I have managed to set up a decent A. I. I am now tweaking the A. I so that it looks better and realistic. One of the area I would want to tweak is what happens when the player receives the ball. Currently the ball stops dead at the player's feet. I would want it to be like the player takes note of how much speed the ball is travelling with and the player decides on how much force he should use so that the ball stops in front of him. I know depending on the player's ball control states I can use it to decide a certain range of power the player can use (players with less accuracy have a greater range increasing there chances of making errors). I haven't tried it yet so any ideas on how to do this will be greatly appreciated.
  4. I would have liked to mark all your answers correct. Well Matt Buckland's book is the base of this project and I am trying to add to that. I have implemented the whisker technique, though not perfect its decent.
  5. Well I  have been working on a soccer game for the past few months ("still learning unity 3d. its my first game"). I have recently come across some minimum path finding algorithms in my studies ( Prim's algorithm, Djikstra algorithm, a*, fFyod etc). I have been thinking of adopting one of these algorithm into my game to help in the players navigating around the soccer pitch to reach the opponents goal. This algorithm will be used during player dribbling and the map will be periodically updated or i was thinking the dribbler will create a map  and decide which path to go to minimize resource usage. I know the best way of learning is trial and error but I would love some heads up on this one. So what do you think I should do
  6. I wil do that again. the thing is when I Instantiate the RedTeam only it works well but when I try to Instantiate the blue team it does not work.The same script is attached to two dirrerent soccerteam objects. So the script test which tag the gameobject it is attached to has and populates the player's accordingly. I am not sure were the problem is coming from but i wil check
  7. I have two empty game objects (BlueTeam and RedTeam). The BlueTeam needs to set its opponent as the RedTeam and vice versa. When a team is instantiated it as to generate its players and place them on there home regions which are created when I Instantiate the pitch. When I instantiate one team only my players appear at the correct positions with no error. When I try to instantiate both teams at the same time I have a "Null Exception The Object which you are trying to reference doe not exist". I know what the error means but I cant seem to get why that is happening.The code is in C# Here is some code of what I am trying to do. Here is my start function for my SoccerPitch     // Use this for initialization void Start() { //create the soccer ball m_pBall = Instantiate(m_pBall) as SoccerBall; //create the teams m_pRedTeam = Instantiate(m_pRedTeam) as SoccerTeam; m_pBlueTeam = Instantiate(m_pBlueTeam) as SoccerTeam; m_bGameOn = true; m_bGoalKeeperHasBall = false; m_bPaused = false; }   Here is my Start function for my SoccerTeam              // Use this for initialization         void Start () {         //initialize soccerball         m_pPitch = GameObject.FindGameObjectWithTag("soccerpitch").GetComponent<SoccerPitch>();                         //initilize team home regions         if(transform.tag == "redteam")         {         m_pHomeGoal =  GameObject.FindGameObjectWithTag("redgoal").GetComponent<Goal>();         m_pHomeGoal.m_vFacing = new Vector3(0,1,0);         GeneratePlayers(m_pPlayersHomeRegions);         m_pOpponents = GameObject.FindGameObjectWithTag("blueteam").GetComponent<SoccerTeam>();         m_POpponentsGoal = GameObject.FindGameObjectWithTag("bluegoal").GetComponent<Goal>();                 }                         if(transform.tag == "blueteam")         {                 m_pHomeGoal = GameObject.FindGameObjectWithTag("bluegoal").GetComponent<Goal>();         m_pHomeGoal.m_vFacing = new Vector3(0,-1,0);     m_pOpponents = GameObject.FindGameObjectWithTag("redteam").GetComponent<SoccerTeam>()            m_POpponentsGoal = GameObject.FindGameObjectWithTag("redgoal").GetComponent<Goal>();         //create players for this team         GeneratePlayers(m_pPlayersHomeRegionsblue);         }                 m_pReceivingPlayer = null;                  }     Here is my start unction for my Field player.        // Use this for initialization     public void Start(){         m_vVelocity = new Vector3(0,0,0);     m_vHeading = new Vector3(0,0, 0);     rigidbody.velocity = new Vector3(0,0, 0);     //m_pBall = GameObject.FindGameObjectWithTag("soccerBall");     m_pSteering = new SteeringBehaviours(this.gameObject.GetComponent<FieldPlayer>(), GameObject.FindGameObjectWithTag("soccerBall").GetComponent<SoccerBall>());             //initilize the statemachine     m_pStateMachine = new StateMachine<FieldPlayer>(this);     //intilize the states     m_pStateMachine.SetCurrentState(Wait.Instance());     this.Steering().SetTarget(this.HomeRegion().Pos());     //set the players start position     transform.position = (this.HomeRegion()).Pos() ;         }     The Null Exception error points me to the FieldPlayer's start function where I try to set the position of the FieldPlayer (transform.position = (this.HomeRegion()).Pos() ;)  
  8. Hie. I am making a soccer game in unity3d.I am having problems manipulating my objects in 3d. The problem is caused by the center of gravity on my objects.For example when I try to chase a ball using a steering behavior I get some weird results because the my direction vector is pointing from the player'rs center of gravity to the ball's center of gravity. so in general the player tries to move his center of gravity to the ball's center of gravity which results in some cases the player pushing through the field.Any help will be appreciated
  9. i will implement the joypad at a later stage for now i just want to use the keyboard.so are using i should have like a while loop.for example if i press the up buttton a certain boolean is set true and i call a certain function whilst this boolean is true.
  10. guys i need help on how i can implement a way on how to read multiple key pressing from the keyboard e.g like when i am pressing the left key and a i press the shoot or pass button i want my player to pass the ball.Currently my game agent stops responding for a while when i press another key .e.g when i press the up button from the left button the player stops for a while and then heads upwards.i want the movements to be smooth           public void keyPressed(KeyEvent e) {                                  if(g_SoccerPitch.GameOn() && g_SoccerPitch != null){                                  switch (e.getKeyChar()) {                                             case 'w':                     case 'W':{                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveUp();                         chaseBall();                     }                     break;                                          case 's':                     case 'S':{                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveDown();                        chaseBall();                     }                     break;                                          case 'a':                     case 'A':{                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveLeft();                         chaseBall();                     }                     break;                                          case 'd':                     case 'D':{                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().MoveRight();                         chaseBall();                     }                     break;                                              case 'm':                     case 'M':{                          //shoot ball if ball withinin kicking range and team is in control                          if(g_SoccerPitch.UserControlledTeam.InControl() && g_SoccerPitch.UserControlledTeam.UserControlledPlayer().BallWithinKickingRange()){                           g_SoccerPitch.UserControlledTeam.UserControlledPlayer().UserPlayerShootBall();                          }                        }                     break;                                              case 'l':                     case 'L':{                          //if team in control pass the ball else chase the ball                          if(g_SoccerPitch.UserControlledTeam.InControl()){                                                  if(g_SoccerPitch.UserControlledTeam.UserControlledPlayer().BallWithinReceivingRange()){                           g_SoccerPitch.UserControlledTeam.UserControlledPlayer().UserPlayerPassBall();                            }                             }  else{                                                  g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SeekOn();                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SetTarget(g_SoccerPitch.Ball().m_vPosition);                         if(g_SoccerPitch.UserControlledTeam.UserControlledPlayer().AtTarget()){                         g_SoccerPitch.UserControlledTeam.UserControlledPlayer().Steering().SeekOff();                         }                          }                     }                     break;                 }//end switch   here is my code snippet and its in java
  11. Hie guys i am trying to impplement the Offside rule in my soccer game. I am using Programming Game AI by example doingbthe java version.I have done throw in, goal kick and corner kick, now i have a problem on implementing the offside.Can anyone please tell me how I can do this     /**      *  this demo works on a fixed frame rate (60 by default) so we don't need      *  to pass a time_elapsed as a parameter to the game entities      */     public void Update() throws InterruptedException {         if (m_bPaused) {             return;         }         //update the balls         m_pBall.Update();         //update the teams         m_pRedTeam.Update();         m_pBlueTeam.Update();         //if a goal has been detected reset the pitch ready for kickoff         if (m_pBlueGoal.Scored(m_pBall) || m_pRedGoal.Scored(m_pBall)) {             m_bGameOn = false;             //reset the ball                                                                   m_pBall.PlaceAtPosition(new Vector2D((double) m_cxClient / 2.0, (double) m_cyClient / 2.0));             //get the teams ready for kickoff             m_pRedTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             m_pBlueTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());         }        //call is throw in method        isThrowIn(m_pBall);        //call is corner kick method        isCornerKick(m_pBall);                itsAnOffSide();     }          /*public void itsAnOffSide(){         if(m_pRedTeam.InControl() && m_pRedTeam.isOffSideTeamPlayer()== m_pRedTeam.Receiver()){             m_pRedTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());         }else if(m_pBlueTeam.InControl() && m_pRedTeam.isOffSideTeamPlayer()== m_pBlueTeam.Receiver()){            m_pBlueTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());         }     }*/     //method to check if its a corner kick or not     public void isCornerKick(final SoccerBall ball) throws InterruptedException{         /*if ball intersects with redteam's goalline whilst the redteam          * was in control its a corner kick         */          if(LineIntersection2D(ball.Pos(), ball.OldPos(), TopLeft, BottomLeft) && m_pRedTeam.InControl()){             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(0, 0));             Thread.sleep(1000);             m_pRedTeam.GetFSM().ChangeState(Defending.Instance());             m_pBlueTeam.GetFSM().ChangeState(Attacking.Instance());             //return true;          }else               /*if ball intersects with redteam's goalline whilst the blueteam                * was in control its a goal kick               */              if(LineIntersection2D(ball.Pos(), ball.OldPos(), TopLeft, BottomLeft) && m_pBlueTeam.InControl()){              m_bGameOn = false;              m_pBall.PlaceAtPosition(new Vector2D(150, 100));              Thread.sleep(1000);              m_pRedTeam.GetFSM().ChangeState(Attacking.Instance());              m_pBlueTeam.GetFSM().ChangeState(Defending.Instance());            // return true;          } else/*if ball intersects with blueteam's goalline whilst the blueteam                * was in control its a corner kick               */         if(LineIntersection2D(ball.Pos(), ball.OldPos(), TopRight, BottomRight) && m_pBlueTeam.InControl()){             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(700, 400));             m_pRedTeam.GetFSM().ChangeState(Attacking.Instance());             m_pBlueTeam.GetFSM().ChangeState(Defending.Instance());             //return true;         }else/*if ball intersects with blueteam's goalline whilst the blueteam                * was in control its a corner kick               */         if(LineIntersection2D(ball.Pos(), ball.OldPos(), TopRight, BottomRight) && m_pRedTeam.InControl()){             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(600, 250));             m_pRedTeam.GetFSM().ChangeState(Defending.Instance());             //m_pBlueTeam.SetControllingPlayer(m_pBlueTeam.GetPlayerFromID(tick));             m_pBlueTeam.GetFSM().ChangeState(Attacking.Instance());             //return true;         }         //return false;     }          /*     *method to check if ita a throw in or not,     *checks which team was in control whenn the ball intersected with the walls;     ball position is reset and the controlling team return to its home region     */     public  void isThrowIn(final SoccerBall ball) throws InterruptedException {         if (LineIntersection2D(ball.Pos(), ball.OldPos(), TopLeft, TopRight)&& m_pRedTeam.InControl()) {             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(ball.OldPos().x, ball.OldPos().y));             Thread.sleep(1000);             m_pRedTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             //m_pBlueTeam.GetFSM().ChangeState(Defending.Instance());             //return true;         }else if (LineIntersection2D(ball.Pos(), ball.OldPos(), TopLeft, TopRight)&& m_pBlueTeam.InControl()) {             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(ball.OldPos().x, ball.OldPos().y));             Thread.sleep(1000);             m_pBlueTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             //m_pBlueTeam.GetFSM().ChangeState(Defending.Instance());             //return true;         }else if(LineIntersection2D(ball.Pos(), ball.OldPos(), BottomLeft, BottomRight) && m_pRedTeam.InControl()){             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(ball.OldPos().x, ball.OldPos().y));             Thread.sleep(1000);             m_pRedTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             //return true;         }else if(LineIntersection2D(ball.Pos(), ball.OldPos(), BottomLeft, BottomRight) && m_pBlueTeam.InControl()){             m_bGameOn = false;             m_pBall.PlaceAtPosition(new Vector2D(ball.OldPos().x, ball.OldPos().y));             Thread.sleep(1000);             m_pBlueTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             //return true;         }         //return false;     } /*     method which returns the closest player to own goal     */      private PlayerBase CalculateClosestPlayerToOwnGoal(SoccerTeam team) {                    double ClosestSoFar = MaxFloat;          for(int i =0; i < team.Members().size();i++){              if(team.Members().get(i).m_PlayerRole == attacker || team.Members().get(i).m_PlayerRole == defender){              double dist = Math.sqrt(Math.pow(team.Members().get(i).Pos().x - team.HomeGoal().Center().x,2));              if( dist < ClosestSoFar){                                     m_pPlayerClosestToHomeGoal = team.Members().get(i);              }                                    }          }          return m_pPlayerClosestToHomeGoal;     }      /*        *method which returns a player who is nearest to the opposition goal      */       private PlayerBase CalculateClosestPlayerToOppGoal(SoccerTeam team) {                    double ClosestSoFar = MaxFloat;          for(int i =0; i< team.Members().size();i++){              if(!team.Members().get(i).isControllingPlayer()){              double dist = Math.sqrt(Math.pow(team.Members().get(i).Pos().x - team.OpponentsGoal().Center().x,2));              if( dist < ClosestSoFar){                                     m_pPlayerClosestToOppGoal = team.Members().get(i);              }          }          }          return m_pPlayerClosestToOppGoal;     }              public void itsAnOffSide(){           if(m_pBlueTeam.HomeGoal().Center().x - CalculateClosestPlayerToOppGoal(m_pRedTeam).Pos().x                   < m_pBlueTeam.HomeGoal().Center().x - CalculateClosestPlayerToOwnGoal(m_pBlueTeam).Pos().x                   && m_pPlayerClosestToOppGoal.BallWithinReceivingRange()){                   //){              m_bGameOn = false;                //reset the ball                                                                   m_pBall.PlaceAtPosition(new Vector2D((double) m_cxClient / 2.0, (double) m_cyClient / 2.0));             //get the teams ready for kickoff             m_pRedTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());             m_pBlueTeam.GetFSM().ChangeState(PrepareForKickOff.Instance());           }       }   That is the code to do the calculations. Can someone tell me where Iam going wrong or if there is a better option
  12. okay i think this one will work i will try it.the system must not update the state of the controlling player only whilst the rest are being handled by the AI.then this player's behaviours are going to be affected by the keyboard input. is that right?
  13. that is exactly what i want t do. a user sholud directlty control the player. i was thinking of if a user chooses a team the user controlling player should read input from the keyboard and overide the AI whilst the other players are handled by the AI.Is that possible
  14. that is exactly what i want t do. a user sholud directlty control the player. i was thinking of if a user chooses a team the user controlling player should read input from the keyboard and overide the AI whilst the other players are handled by the AI.Is that possible
  15. Hie guys i am developing a soccer game. I used programming game ai by example as my basis. I am doing the java version of it. I want someone to help on how to code some of the features i want to add. Like now i am trying to implement a user controlled team. I need help on this. I wolud also like to implement some soccer rules like offside and throw in. If someone can help me your help will be greatly appreciated. On how to control the team i decided to add another class called 'USERCONTROLLED' class. This class takes in a soccerteam as a parameter and has an instance o f the soccerpitch. The class has methods like moveUp ....... This class is instantiated in the main where it receives a soccer parameter like this(UserControlledTeam team = newUserControlledTeam(g_SoccerPitch.m_pRedTeam). When i try to run the code it gives me the Initilizer Error. i need help on how i can get around this or if there is a better way of doing this What I need help on is given an AI that is already running how do you alter it so that you have a team controlled by a user vs an team controlled by the AI.I have uploaded the source code of the game. It does not have the alterations i taked about.[attachment=20830:NHABVU.zip]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!