View Full Version : Problem Spawning a pawn that will attack me
legacy-Yining
09-10-2003, 01:54 PM
I have been writing a script for an object that spawns a pawn during gameplay. I have the basics down, I spawn a pawn, then I spawn a controller and do a pawn.possedby(controller) to give the pawn a controller. When the pawn is spawned during game however, it simply walks around and it simply goes around me. It somehow doesn't realize that I am an enemy. Am I not initializing pawn correctly? Also, when my pawn dies, it respawns too, how can I make sure that once he dies, he doesn't come back?
legacy-segall
09-11-2003, 05:55 AM
It's the controller that possesses a pawn, not the other way around. The pawn.PossessedBy( ) is called by the controller to notify the pawn that it has been possessed, it does not do the actual possession.
Try this: myController.Possess(myPawn);
To prevent a pawn from respawning, do this in the controller:
state Dead
{
function ServerRestartPlayer ()
{
// stub
}
}
legacy-Yining
09-11-2003, 09:26 PM
The pawn walks around when I do the Possess function, but he still does not want to kill me.When I add the
State Dead ...
in the controller, do I do it in the player controller? or the controller of my pawn? Additionally, does anyone know what "SpawnBot" does? Could I use that instead of Spawn? Thanks for all your help.
legacy-athos_musketeer
09-11-2003, 10:38 PM
the same happened to me.
i have my own enemy that extends from xPawn.
but when i place it in a level. it doesn't even move.
i had to write my own Roster and RoterEntry class so the spawned ones are the same enemies, but they all doen't move.
i believe it has something to do with the controller class.
becuase the log has some warn about a none access. i believe it's the squad var ( var SquadAI Squad).
maybe we can work it out.
:)
thanks to all
legacy-segall
09-11-2003, 10:48 PM
I don't know why he doesn't want to kill you. Maybe you changed some behavior. Anyway, that is the correct way to do possession.
SpawnBot( ) is called by AddBot( ) to do what else, spawn a AI CONTROLLER in the level. It further calls RestartPlayer( ) which assigns a pawn to the controller if it doesn't have one. If you want to play around with bot spawning for a gametype, stub out AddBot( ) as it's the one where the bot spawn process originates from.
legacy-Yining
09-11-2003, 11:30 PM
I was looking at the AddBot() yesterday, but there is one thing I don't know how to do. AddBot() is in xDeathMatch and I don't know exactly how to call it from another calss. Can I do something like level.GameType.AddBot() to add a bot? I have scoured LevelInfo and have found no references to GameType. I also looked in my controller class and have also found nothing referring to a game type. What I want to try is call AddBot from a class that I created to respond to triggered events. Can I actually do that? I mean to call something like level.GameType.AddBot(Of course the names of the classes and methods are different) from an abitary class?
For my pawns AI, I just extended off of "Bot". I had set a few attributes, like bHunting=true, skill=8(I really want him to shoot me),bShootTarget=true, and bHuntPlayer=true. I added these things just so the pawn would be more agressive, should I add anything else to change his behavior?
Segall, how long have you been working with Uscript? I just started (as you can probably infer from my questions). How did you learn all these things about Uscript? The internet doesn't offer too much information these fields.
Thanks everyone for helping me!
legacy-athos_musketeer
09-11-2003, 11:45 PM
Yining you have to make your own class that extends of xDeathMatch.
and also overwrite the function you want to add funcionality
eg:
class MyGame extends xDeathMatch;
Function Bot AddBot( Controller C )
{
// Here you are calling the xDeathMatch.AddBot
// or the parent of it
super.AddBot( C );
// add some funcionality in here
}
here is an excellent place to look for info:
http://wiki.beyondunreal.com
hope it helps
legacy-Grimfort
09-12-2003, 10:31 AM
I dont suppose that the bot your spawn thinks he on the same team as you ? Or doesnt think your an enemy at least.
Try just adding a few bots to the game, and see what the spawned bot does.
legacy-Yining
09-12-2003, 09:00 PM
I forgot what I did, but I remember that when I used to kill the pawns that I spawned, new ones would popup and would start attacking me. But just incase the pawns I spawn think I am on the same team, is there anyway I can change its team number?
legacy-=HaZZard=
09-13-2003, 05:21 PM
If any 1 finds out how post a reply
HERE (http://sv2.3dbuzz.com/vbforum/unr_showthread.php?s=&threadid=38912&perpage=10&pagenumber=1) plz weve tryed everything u can think ov. Tnx.
legacy-Yining
09-14-2003, 10:00 PM
Hi Everyone, I finally figured out how to spawn a bot that will kill me. I just remade my AddBot() and SpawnBot functions and called AddBot when I needed to. There is however one problem though, the enemy teleports in at my playerstart, not at where I want it to. I really think this problem is in the restart() of game info. If you look at the end of AddBot(), you'll see a call to RestartPlayer(). What I am trying to do is to change the StartSpot variable in the RestartPlayer(), but when ever I set StartSpot to anything, the bot doesn't appear. In RestartPlayer(), there is this line that is something like this: StartSpot = FindPlayerStart(...). What I did was set StartSpot to spawn(class'NavigationPoint'), since that is the variable type of StartSpot. Theoretically speaking, wouldn't that set StartSpot to a navigationpoint with the location of the class where all this is taking place(I am writing all this in a placeable object)? When I do this however, the Bot never spawns. Also, when I do a setlocation for the StartSpot in RestartPlayer(), nothing happens either. Does anyone have any clues as to how I can set the StartSpot to a location I want? Am I in the right direction? Thanks.
legacy-Grimfort
09-15-2003, 04:21 AM
All your doing with AddBot() is adding a both like a normal player, not like what you really want. Its the same as picking to start the game with 4 bots instead of 3.
Try looking into expanding on the player start, but making it more of a BotStart class.
legacy-=HaZZard=
09-15-2003, 04:49 AM
Hiya ive got it to spawn an bot that will attack you. what you do is get an xPawn and place it in your level, then go into its properties and serlect a diffrent modle you want it to use.(the model you want has to be serlected in the animations section)then in its propoties click use serlected. then you have to change its texture so under the skin rollout in the xPawn props change it to the texture for that modle. then add an scripted AISec and link it to your xPawn then change the pysics to walking and change the controller to bot or xBot. the pawn will now attack you BUT!! it floods random bots out of your playerstart and i dont know how to stop it!:mad: :mad: :mad:
legacy-Grimfort
09-15-2003, 02:21 PM
The problem with adding an Pawn by hand in map design, is that you cant control when they appear (as you found out). The best way is to impliment a CreateBot object (base it on the PlayerObject). when you create the bot, you can pass yourself as the spawnpoint in which to create the bot. You can then make it make the bot on the trigger event.
Its something that I need to impliment as well in a few weeks and thats the line I will probly take.
legacy-Yining
09-17-2003, 05:15 PM
Hi Guys, I figured out how to spawn a pawn that will kill me. Let me tell you how to do it. I first spawned a pawn and set its controller to an AI controller, then I did a Init() for the pawn so it gets set. Look at AddBot and Init() in Deathmatch for the detials. Once it does that, your pawn will spawn in the level, the only problem is that he will not attack you. That was my problem for a long time... Then I found out that the reason he didn't attack me was because he didn't have weapons, I added something to the effect of AddDefaultInventory to give him a weapon. Now I can get killed when I play!!! Hope this helps the other guys who are having the same tribulations
legacy-=HaZZard=
09-22-2003, 03:50 AM
Well we all ow u a BIG THANKS! Over at Masteringunreal.com weve been trying to solve this problem for ages so on behalf ov all the people over there who put shuch hard work into the process of helping solve the problem i would like to THANK YOU!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.