Results 1 to 40 of 40

Thread: 'Patient' Pawn

  1. #1
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default 'Patient' Pawn

    I'm trying to make an NPC that stands still until it sees the player, rather than one that wanders until it encounters said player. I'm no programmer, and certainly no AI programmer, but programming inaction should be a breeze. Should be.
    I have a script (not mine, UDN's) that starts in state 'Idle', and goes to state 'Chase' upon seeing the player. The problem is that even then, with no instructions given to the bot in that state, the pawn wanders from navigation point to navigation point until finding the player and/ or enemies. The script extends from AIController, and it is as basic as possible, so it isn't extending some wandering state.
    I would have used XNASorcerer's spectacular stealth ai script, but all but one or two of his 25-40 threads have been wiped clean by the mods.

  2. #2
    MSgt. Shooter Person
    Join Date
    Mar 2011
    Location
    Quebec, Canada & Florida, USA
    Posts
    279

    Default

    do you have the word "auto" before "state Idle"? this will make the AI go directly in idle state, also are you using the right AI Pawns in your level?

  3. #3
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    UDK_lover-yes, the word "auto" is in front of the words "state Idle." I don't quite know what you mean in your second question, but I'll guess. If you mean, "does the pawn script specify the current controller?" then, yes. If you mean "does your game file use the correct pawn/bot class?" then the answer is still yes.

  4. #4
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    Okay, here is the code:

    Code:
    class StealthBot_Test extends AIController;
    
    var Actor Player;
    
    var Vector TempDest;
    
    var float playerDistance;
    
    Defaultproperties
    {
    }
    simulated event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	super.Possess(inPawn, bVehicleTransition);
    
    	Pawn.SetMovementPhysics();
    }
    
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		super.SeePlayer(Seen);
    		Player = Seen;
    
    		playerDistance = VSize ( Pawn.location - Player.location );
    
    		if( playerDistance < 200 )
    		{
    			GotoState('Idle');
    		}
    		else
    		{
    			GotoState('Chase');
    		}
    	}
    Begin:
    
    }
    
    state Chase
    {
    ignores SeePlayer;
    
    function bool FindNavMeshPath()
    	{
    		NavigationHandle.PathConstraintList = none;
    		NavigationHandle.PathGoalList = none;
    
    		class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle, Player );
    
    		return NavigationHandle.FindPath();
    	}
    
    Begin:
    Player = GetALocalPlayerController().Pawn;
    
    playerDistance = VSize( Pawn.location - Player.location );
    
    if( playerDistance < 2100 )
    {
    	GotoState('Shoot');
    }
    else if( NavigationHandle.ActorReachable( Player ) )
    	{
    
    
    		MoveToward( Player,Player, 100 );
    	}
    	else if( FindNavMeshPath() )
    	{
    
    		NavigationHandle.SetFinalDestination(Player.Location);
    
    		NavigationHandle.DrawPathCache(,TRUE);
    
    		if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) )
    		{
    			DrawDebugLine(Pawn.Location,TempDest,0,255,0,true);
    			DrawDebugSphere(TempDest,16,20,0,255,0,true);
    			MoveTo( TempDest, Player );
    		}
    	}
    	else
    	{
    		GotoState('Idle');
    	}
    	goto 'Begin';
    }

  5. #5
    Iron Guard
    Join Date
    Jun 2008
    Posts
    818
    Gamer IDs

    Gamertag: Black Fang666

    Default

    I don't remember if goto starts at the begin label or if you have to use beginstate(Statename)... But I don't think that would be the problem anyway...
    Want to collaborate? Want to chat UDK? Message me on Skype, Craig Delancy. Check out my UDK Youtube channel: http://www.youtube.com/user/xblBlack...ew=0&flow=grid

  6. #6
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    skwisdemon666-Thanks for responding. This is a script right off of a UDN tutorial, so I don't think there would be any inconsistencies. However, I'm willing to try nearly anything that may have any remote chance of changing the outcome for the better. Though, due to my brittle understanding of code, I don't quite get what you mean.

  7. #7
    MSgt. Shooter Person
    Join Date
    Mar 2011
    Location
    Quebec, Canada & Florida, USA
    Posts
    279

    Default

    What I meant was: In your map/level, you placed an instance/object of your custom AIPawn class right? Make sure it is the instance of the correct AIPawn class.

    You can check by clicking on it, and looking at the bottom of the screen in the editor, if it says something like MyAIPawn_0, or just in the properties panel by pressing F4 after you clicked on it

  8. #8
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    UDK_lover: Actually, I was placing the pawn at runtime via kismet. But, in answer to your question, yes. When the pawn is added via actor classes window, it shows up in the properties and at the bottom of the screen as being StealthPawn_Test_0. Now when the game is played, the pawn does not move at all whatsoever, despite both the pawn code and pawn property windows indicating StealthBot_Test, the controller script in question. Though that is a separate problem.

  9. #9
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    0. Code should working except GotoState('Shoot'); - there is no such state... Remove that call.
    1. Remove Player = GetALocalPlayerController().Pawn; - you don't need this...
    2. Move Defaultproperties at end of script
    3. Just to be sure: You need at last one Pylon in your level to make NavMesh work...
    Last edited by VendorX; 04-13-2012 at 06:20 PM.

  10. #10
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-0. I wasn't sure how much to remove, so I changed the call to got to state "Chase" instead. 1. Okay, removed. 2. Okay, even I should have seen that. Thanks. 3. Okay, I placed a pylon, and the script works perfectly. Though the character inexplicably aims straight down, which will look weird in a stealth game. Overall, though, exactly what I wanted. I'll do some research on the use of pylons vs. nav points.

  11. #11
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    If you don't know how to remove that call then add this state.
    i.e.
    Code:
    state Shoot
    {
    Begin:
    	Sleep(1.0);
    	GotoState('Idle');
    
    }
    ...and change if( playerDistance < 2100 ) to if( playerDistance < 200 )

  12. #12
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-Thanks again. I had the playerDistance detection set to such a high number because I'd previously used that code for a sniper, and at the time thought that'd help the pawn not shoot at point blank range. Then again, I don't really know what that does, so, yeah. I'll probably leave that alone for now.

  13. #13
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    I realize it's probably a bit of a tangent from the aim of this thread, but I also want to cap the pawn's sight distance. I can't find anything to reference from the pawn scripts, so I was thinking I could use the bot script. By modifying:

    Code:
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		super.SeePlayer(Seen);
    		Player = Seen;
    
    		playerDistance = VSize ( Pawn.location - Player.location );
    
    		if( playerDistance < 200 )
    		{
    			GotoState('Idle');
    		}
    		else
    		{
    			GotoState('Chase');
    		}
    	}
    However, it seems as though that value, even if reduced to 0.001 (yes, I did get that desperate) does nothing to keep the pawn from having an unlimited view range. Maybe something in SeePlayer?

  14. #14

    Default

    what about if( playerDistance > 200 ) instead of if( playerDistance < 200 )?

    i think if( playerDistance < 2100 ) should be changed to if( playerDistance < 1 ) or sth. Seems the bot will do nothing if it's true, since the bot just sleep when Shoot.
    I suppose you want the bot to do something when the player is near.
    Last edited by douxt; 04-14-2012 at 01:10 AM.

  15. #15
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    In Pawn:
    Code:
    var(AI) float SightRadius;	// Maximum seeing distance.
    var(AI) float PeripheralVision;	// Cosine of limits of peripheral vision.
    If still nothing:

    Code:
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		super.SeePlayer(Seen);
    		Player = Seen;
    
    		playerDistance = VSize ( Pawn.location - Player.location );
    
    		if( playerDistance < 200 )
    			GotoState('Chase');
    	}
    }
    Don't forget to changing other too...
    Last edited by VendorX; 04-14-2012 at 04:57 AM.

  16. #16
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    Sorry for the late response. Internet connectivity these days.

    douxt-Yeah, I kinda wondered about the less than/greater than sign. I tried changing it, a few times over, to no avail.
    VendorX- Yet again, the master speaks. Thanks. I'd seen the sight radius thing, but the word 'radius' made be think of a cone representing the field of view.

    Now, however, I have to address the original problem again. The pawns are still moving around. When I added a pylon to the scene, the bot's actions improved. So I worked around the problem by just placing a pylon, and featuring no path nodes (or at least, active ones) in the environment.

    However, my test stealth environment is getting more complex, and I am needing to make use of path nodes in certain areas. How would I go about fixing this elusive problem?

    Also, I will repost my current code if you want or need. Just don't expect urgency, the weather's getting nasty on this part of the planet.

  17. #17
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Quote Originally Posted by MRTeague View Post
    I'd seen the sight radius thing, but the word 'radius' made be think of a cone representing the field of view.
    var(AI) float SightRadius; // Maximum seeing distance. - 360' around...
    var(AI) float PeripheralVision; // Cosine of limits of peripheral vision. - this is cone...

    Quote Originally Posted by MRTeague View Post
    Now, however, I have to address the original problem again. The pawns are still moving around. When I added a pylon to the scene, the bot's actions improved. So I worked around the problem by just placing a pylon, and featuring no path nodes (or at least, active ones) in the environment.
    Code it self is the problem - you all using wrong code, with many errors and mistakes made by author (like Mogoli or XNASorcerer). Instead of each time when you want implement new functionality, first check maybe there is already... First and worst error is using custom variable Target to chase PC - in Controller you have already declared Enemy. Native code is using Enemy to predict AI behavior and/or trigger some events like i.e. EnemyNotVisible. Navigation system is not like should be to - i.e. when Bot is moving to the next TempDest and meanwhile will see the Player, he will try first reach that point (even if it is very far...) - madness...

    Anyways, your bot still moving around because Player is not None and he will stay in state Chase forever... Use Enemy and put EnemyNotVisible in to state Chase, in that event set Player to None - Bot should switch state to Idle and stop moving.

    Quote Originally Posted by MRTeague View Post
    However, my test stealth environment is getting more complex, and I am needing to make use of path nodes in certain areas. How would I go about fixing this elusive problem?
    I'm not sure what you mean...

  18. #18
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    var(AI) float SightRadius;
    Yes, I understand that now. I was simply stating what I had thought beforehand.
    Code it self is the problem
    So, what you mean is, the code defines many things that don't need definition, and is causing trouble? I'll look into your (strongly) suggested changes.
    I'm not sure what you mean...
    I made an old file representing a 1940's film set for testing lens flares (I'm a bit ambitious). I'm repurposing it to make a stealth scene, but the service catwalks are too high and narrow to use pylons for pathfinding. Assuming that's even possible to begin with. However, if the code, not the environment, is the issue, I'll change the code.

  19. #19
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-Upon looking at your post more carefully, I think I understand what you are saying. To an extent, at least. I believe you are saying that: 1. the custom variable 'Player' is unnecessary and could simply be replaced by the already-default 'Enemy' variable, extended from Controller (which I've now done), 2. the pawn will walk to the path node closest to the player, rather than to the player itself, and 3. that the 'chase' state defines who it is that the pawn should be chasing, rather than basing it on whether or not the player is in view. Please correct me if I've misunderstood.

    Bot should switch state to Idle and stop moving.
    The problem, though, is not that the bot will chase after my character, and even after loosing sight, will still be walking around. The problem is that so long as there is even one active path node or navigational waypoint (vehicle, weapon spawn) the pawn will start out running around and inexplicably hopping, until spontaneously dying, even without seeing the player at all, or being in the 'chase' state.

  20. #20
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    1. That's good...

    2. No... Imagine when Bot have Enemy from the beginning, but don't see it - in this situation NavigationHandle will try to find way to Enemy. Sometimes distance between two points is big e.g. 2000uu, now after start moving when he will see Enemy he will not change his strategy, because in code (which you all using...) there is no such possibility - first he will go to that point, even if Enemy will be in the middle.

    3. Once he enter to state Chase, he will start looping - Begin, FindNavMeshPath, MoveTo (which is latent...).

    Quote Originally Posted by MRTeague View Post
    The problem is that so long as there is even one active path node or navigational waypoint (vehicle, weapon spawn) the pawn will start out running around and inexplicably hopping, until spontaneously dying, even without seeing the player at all, or being in the 'chase' state.
    You doing something wrong - he should stay still until he see the player. Post YourPawn and YourAI code.

  21. #21
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX- Pawn code:

    Code:
    class StealthPawn_Test extends UTPawn
      placeable;
    
    defaultproperties 
    {
      ControllerClass=class'AI.StealthBot_Test'
      SightRadius=+1600.0
      PeripheralVision=+45.0
      GroundSpeed=350.0
    }
    Bot code:
    Code:
    class StealthBot_Test extends AIController;
    
    var Vector TempDest;
    
    var float EnemyDistance;
    
    
    simulated event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	super.Possess(inPawn, bVehicleTransition);
    
    	Pawn.SetMovementPhysics();
    }
    
    
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		super.SeePlayer(Seen);
    		Enemy = Seen;
    
    		EnemyDistance = VSize ( Pawn.location - Enemy.location );
    
    		if( EnemyDistance < 200 )
    			GotoState('Chase');
    	}
    Begin:
    
    }
    
    state Chase
    {
    ignores SeePlayer;
    
    function bool FindNavMeshPath()
    	{
    		NavigationHandle.PathConstraintList = none;
    		NavigationHandle.PathGoalList = none;
    
    		class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle, Enemy );
    
    		return NavigationHandle.FindPath();
    	}
    
    Begin:
    
    EnemyDistance = VSize( Pawn.location - Enemy.location );
    
    if( EnemyDistance < 200 )
    {
    	GotoState('Shoot');
    }
    else if( NavigationHandle.ActorReachable( Enemy ) )
    	{
    
    
    		MoveToward( Enemy,Enemy, 100 );
    	}
    	else if( FindNavMeshPath() )
    	{
    
    		NavigationHandle.SetFinalDestination(Enemy.Location);
    
    		NavigationHandle.DrawPathCache(,TRUE);
    
    		if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) )
    		{
    			DrawDebugLine(Pawn.Location,TempDest,0,255,0,true);
    			DrawDebugSphere(TempDest,16,20,0,255,0,true);
    			MoveTo( TempDest, Enemy );
    		}
    	}
    	else
    	{
    		GotoState('Idle');
    	}
    	goto 'Begin';
    }
    
    
    state Shoot
    {
    Begin:
    	Sleep(1.0);
    	GotoState('Idle');
    
    }
    
    
    Defaultproperties
    {
    }
    Edit: I was going to list the specifications for how I placed the actors in my level, and found that 'force deathmatch ai' was checked. I unchecked it and found that two of the four pawns stayed in place, even with active path nodes in the environment. The other two moved, but only a short distance. However, they are all facing straight down by default, not useful if I want them surveying for the player. Also, I am spawning the pawns via kismet in a VCTF game.
    Last edited by MRTeague; 04-16-2012 at 07:29 PM.

  22. #22
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    Sorry for the bump. A few more tests seem to show that the pawns will head toward a dead pawn to pick up weapons/ammo, then they have trouble with spontaneously jumping/dying. Also, how do I set the 'enemy' variable to none, like VendorX says?

  23. #23
    MSgt. Shooter Person
    Join Date
    Mar 2011
    Location
    Quebec, Canada & Florida, USA
    Posts
    279

    Default

    Is it moving? If not, this happened to me if the pawn placed has 0 health

  24. #24
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    UDK_lover-The pawn, before spontaneously dying, will often move around, either following random pathnodes/waypoints/pickups, or hopping in place. In fact, the moving seems to be what inadvertantly causes the death, as though the programming knows the pawn is not getting where it intends, and kills it for improved processing.

  25. #25
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Quote Originally Posted by MRTeague View Post
    The pawn, before spontaneously dying, will often move around, either following random pathnodes/waypoints/pickups, or hopping in place. In fact, the moving seems to be what inadvertantly causes the death, as though the programming knows the pawn is not getting where it intends, and kills it for improved processing.
    @MRTeague: You're still here..?
    They do this, because you using some sort of UTGame and when there is no NavigationPoint, UTSquadAI will destroy AI Pawn.
    Here is your 'Patient':
    Code:
    class PatientAIController extends AIController;
    
    var Vector TempDest;
    var float EnemyDistance;
    
    simulated event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	super.Possess(inPawn, bVehicleTransition);
    
    	Pawn.SetMovementPhysics();
    
    	`log("********** AI Debug **********");
    	`log("I'm:"@Self);
    	`log("My Pawn is:"@Pawn);
    	`log("My Game is:"@WorldInfo.Game);
    	`log("******************************");
    }
    
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		Super.SeePlayer(Seen);
    
    		if( Seen.Controller == None || !Seen.Controller.IsA('PlayerController'))
    			return;
    
    		EnemyDistance = VSize ( Pawn.location - Seen.location );
    
    		if( EnemyDistance <= 200 )
    		{
    			Enemy = Seen;
    			GotoState('Chase');
    		}
    	}
    Begin:
    	Enemy = None;
    	Focus = None;
    }
    
    state Chase
    {
    	function bool FindNavMeshPath()
    	{
    		NavigationHandle.PathConstraintList = none;
    		NavigationHandle.PathGoalList = none;
    
    		class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle, Enemy );
    		class'NavMeshGoal_At'.static.AtActor( NavigationHandle, Enemy,32 );
    
    		return NavigationHandle.FindPath();
    	}
    
    Begin:
    
    	EnemyDistance = VSize( Pawn.location - Enemy.location );
    
    	if( EnemyDistance <= 300 ) // Follow <= 300 -> Stay and return to Idle
    	{
    		if( NavigationHandle.ActorReachable( Enemy ) )
    			MoveToward( Enemy,Enemy, 100 );
    
    		else if( FindNavMeshPath() )
    		{
    			NavigationHandle.SetFinalDestination(Enemy.Location);
    			FlushPersistentDebugLines();
    			NavigationHandle.DrawPathCache(,TRUE);
    
    			if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) )
    			{
    				DrawDebugLine(Pawn.Location,TempDest,0,255,0,true);
    				DrawDebugSphere(TempDest,16,20,0,255,0,true);
    				MoveTo( TempDest, Enemy );
    			}
    		}
    		else
    			GotoState('Idle');
    	}
    	else
    		GotoState('Idle');
    
    	goto 'Begin';
    }
    
    DefaultProperties
    {
    	 bIsPlayer=true
    }
    I tried keep it simple... In Possess you can find some logs, it's just for debug - find those logs in the Launch.log - especially last one...
    Last edited by VendorX; 04-19-2012 at 01:47 AM.

  26. #26
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    @MRTeague: You're still here..?
    I'm very persistant. Thanks for the script, though I'll have to add some functionalities, such as more persistant chasing techniques, easier detection, and shooting.

    By the way, what game type would you recommend I use, If the 'UT' category of game types had been part of the problem?

  27. #27
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    UTGame is not a problem, write your own AI by extending UTBot and override suicide possibility - look in to ExecuteWhatToDoNext line 1790...

  28. #28
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-I tried extending UTBot to create my own AI Controller class. It seems that we've come full circle, as I cannot get the pawns to actually stay still. I love the UDK and what it has to provide, but I'm growing tired of the nonsense trouble with Controller classes. How did you manage to get the pawns to stay still?

    If I begin the class in auto-state Idle, it should idle, correct? Especially if it doesn't provide an outlet to any other states?

    I pretty much want all of the functionality of UTBot anyway, just with an idle, stealth-friendly initial state. As always, I'll give you the current code, if you wish.

    Edit: Oh, another thing. When you're testing a controller class, how do you apply the script to the pawn? Do you specify it in the pawn class, and/or do you add in in Kismet's actor factory window (and if the latter, with or without force deathmatch ai checked)?
    Last edited by MRTeague; 04-20-2012 at 01:15 AM.

  29. #29
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    This thread is aging fast, so I'll keep it brief. I gave up on extending UTBot, arguably the dumbest thing I've done yet, and have taken to copying, then modifying, VendorX's code (thanks again, by the way).

    However, three problems remain. 1. The bot loses the player too easily. I tried adding another state called 'Search' that is triggered when the bot can no longer see the player, in which the bot is supposed to go to the player's position, regardless of whether the bot can see the player at all. I copied all of the 'chase' state's code over, but that'll go nowhere. So I need to know precisely what it takes to make the pawn move to the player's position.

    2. The pawns don't aim correctly. I added shooting functionality. Not good shooting functionality, but shooting functionality all the same. Still, though, the pawns don't really aim, especially up and down. I looked at an old tegleg script and managed to find the line: Pawn.SetDesiredRotation(Rotator(Normal(P.location) ));. I removed 'P' and added 'Enemy'. The line not only didn't help, but it caused the pawns to fire, strangely, at the -x axis. In retrospect, it didn't work in tegleg's script either (for me), so I've got no idea.

    3. The debugging/path lines show up in the file. I've either removed or commented out several areas, and am not sure what triggers this effect (though I'll admit, it is kind of cool).

  30. #30
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    @MRTeague: Give me that code from post #28 - maybe there is still hope...

  31. #31
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-You mean the code extending UTBot? Uh, okay.

    Code:
    class StealthBot_2 extends UTBot;
    
    var float EnemyDistance;
    
    
    simulated event Possess(Pawn inPawn, bool bVehicleTransition)
    {
    	super.Possess(inPawn, bVehicleTransition);
    	Pawn.SetMovementPhysics();
    }
    
    auto state Idle
    {
    	event SeePlayer (Pawn Seen)
    	{
    		Super.SeePlayer(Seen);
    
    		if( Seen.Controller == None || !Seen.Controller.IsA('PlayerController'))
    			return;
    		EnemyDistance = VSize ( Pawn.location - Seen.location );
    
    		if( EnemyDistance <= 1600 )
    		{
    			Enemy = Seen;
    			GotoState('Hunting');
    		}
    	}
    Begin:
    	Enemy = None;
    	Focus = None;
    }
    
    Defaultproperties
    {
    }
    Not much to it. I've seen several posts saying not much can be done to tame UTBot, though.

  32. #32
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Yeah, but there is nothing - even you removed State Hunting... What this AI should doing, because this is not a Patient..? Why you using NavMesh when extending UT classes - they using PathNode network.

  33. #33
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-So, by extending, I overwrote everything? Then why does the pawn move... well... at all? And continue to engage in combat if shot? Also, where in the script does it say it uses NavMeshes?

    Edit: Wow, a post made entirely of questions. Minus this line.

  34. #34
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Well, UTBot is very complex - you think that when you will write auto state Idle then he will stay in that state..? NOPE... You need more than that... Basically you don't need modify UTBot class to change his behavior - in SquadAI you can do much more, but to do that you need to have a good knowledge about codding an AI.
    If your game is simple, then use UDK as base classes. Don't take me wrong, but UT is not for you - for now...

  35. #35
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-I have no trouble believing that UT code is beyond my understanding. Many posts I've seen indicate UT code is next to impossible to comprehend and adjust without a lot of knowledge.

    I took your suggestion of extending UDKBot, and have applied it to the modified version of your script. The pawns look up and down to shoot at me, but upon shooting, will only fire parallel to the ground. Testing shows this is a controller error. I found a large block of text specifying directional fire and rotators in UTBot, but it has many attached functions I know will cause more trouble than they're likely worth.

    Before I proceed in fixing this, however, I must ask for your permission. I am technically still using your code, so it would probably be best that I ask if this is okay (no sale, redistribution, or self-crediting without consent, of course). Or, for that matter, whether you think I should bother carrying on this oddly persistant thread.

  36. #36
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    All my code example here was based no AIController - stick with that for know... When tested, there wasn't any problem with targeting. YourPawn can be extends from UTPawn - in this way you can use UTWeapons. For future question, here you have Pawn example:
    Code:
    class TestPawn extends UTPawn
    	placeable;
    
    event SpawnedByKismet()
    {
    	if (Controller != None)
    		Controller.SpawnedByKismet();
    	else
    		SpawnDefaultController();
    }
    
    simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)
    {
    	Super.SetCharacterClassFromInfo(class'UTGame.UTFamilyInfo_Liandri_Male');
    }
    
    defaultproperties
    {
    	ControllerClass=class'YourPackage.YourAIController'
    }
    As for permission, you can do what you want - only put my name somewhere...

  37. #37
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    VendorX-I set your code to extend from AIController, and used your example pawn. The pawns are back to not aiming up or down at all, visually or tactically. Out of what may well be desparation, I tried activating a Kismet StartFiringAt event (for testing), only to get the error that the AI code has no handler for such. Might this have something to do with this problem? Or is it an unrelated shortcoming?

    By the way, has anyone else had any problems with the line: Pawn.SetDesiredRotation(Rotator(Normal(Enemy.locat ion) ));. Some threads peg it as the magic answer to all aiming problems, but I can't get the pawns to not aim at the -x axis when it is not commented out. Am I doing something wrong?

  38. #38
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    only put my name somewhere...
    Will this do?

    [IMG][/IMG]

  39. #39
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    In Aim function use YourAIController.Rotation instead of YourPawn.Rotation - Pawn do not rotate in Roll...
    ...or add code below to YourAIController:
    Code:
    simulated event GetPlayerViewPoint(out vector out_Location, out Rotator out_Rotation)
    {
        if (Pawn != None)
        {
            out_Location = Pawn.Location;
            out_Rotation = Rotation;
        }
        else
            Super.GetPlayerViewPoint(out_Location, out_Rotation);
    }
    As for Pawn.SetDesiredRotation, use ClientSetRotation declared in Controller because whatever you do with YourPawn, Controller will reset all rotations you've made...

    BTW. Nice screenshot... ...but in your code or game will be OK...
    Last edited by VendorX; 04-22-2012 at 04:11 AM.

  40. #40
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    148

    Default

    BTW. Nice screenshot... ...but in your code or game will be OK...
    Thanks, I've always been a better artist than coder. Hence my presence here. Though I do like the design. I might just use it...

    In all other areas, thanks again. However, the pawns are still not shooting at me. However, we're getting close. The pawns just seem to have locked on to my character's initial position, and are shooting in whatever direction they first saw me. They try to aim at me again, but will instantly snap back into the previous position before firing. Is there some 'update rotation every () ticks' command I could add?


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.