Units can only be spawned from fixed positions, meaning units cannot spawn inside vehicles so some type of fixed object is required
Forcing Characters into Vehicles! (FAQ)
Moderator: Moderators
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: "W.I.P." Forcing Characters into Vehicles
Though I haven't worked with this issue, I'v read plenty about it, and it seems like many have tried to tackle this issue in the past and failed. Though it seems like you have stummbled upon something, I think the results you get from the error log is just the modtools' way of saying it can't be done. I would just like to quote the docs, though I'm sure that this community has done things the docs say they shouldn't:
-
Ace_Azzameen_5
- Jedi

- Posts: 1119
- Joined: Sat Apr 23, 2005 8:52 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: "W.I.P." Forcing Characters into Vehicles
I'm pretty sure I have the ability right now to force people into multi-person vehicles that have driven through a region. I should probably try that just to prove that EnterVehicle works. Further evidence is that in his Operation Ferret out the Master, Archer01 used ExitVehicle, a similar function. I know this because IIRC the player character alone is forced out of an ATTE at one point, and setobjectteam doesn't work like that. However he likely set that up using the OnEnterRegion with a Character method.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: "W.I.P." Forcing Characters into Vehicles
Argh, why does this subject keep popping up? Wasn't it solved a while ago? If someone can find the links to the original topics about it (the new forum broke all my reference links
), I should be able post the code you need to make it work.
Ace_Azzameen_5, something is wrong with your code/docs. Is it EnterVehicle(player, vehicle) or EnterVehicle(vehicle, player)?
Characters can only be spawned at certain, fixed locations. They can be teleported to more places than spawned. However with teleporting there is an extra problem: if the object/unit/vehicle is not orientated straight, the things being teleported will also not be straight. This causes some weird effects when teleporting a unit to a fighter in the air. Its good for movies, you can do dives into the ground or fall up...
The first error is saying entity 0 does not exist. Entity 0 is normally a player unit, meaning that that player is dead and has yet to respawn.
The second error is saying the given entity is not an EntityFlyer, Hover, or Walker when it should be one of those types.
Ace_Azzameen_5, something is wrong with your code/docs. Is it EnterVehicle(player, vehicle) or EnterVehicle(vehicle, player)?
Characters can only be spawned at certain, fixed locations. They can be teleported to more places than spawned. However with teleporting there is an extra problem: if the object/unit/vehicle is not orientated straight, the things being teleported will also not be straight. This causes some weird effects when teleporting a unit to a fighter in the air. Its good for movies, you can do dives into the ground or fall up...
The first error is saying entity 0 does not exist. Entity 0 is normally a player unit, meaning that that player is dead and has yet to respawn.
The second error is saying the given entity is not an EntityFlyer, Hover, or Walker when it should be one of those types.
-
Ace_Azzameen_5
- Jedi

- Posts: 1119
- Joined: Sat Apr 23, 2005 8:52 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: "W.I.P." Forcing Characters into Vehicles
Yeah, thanks, good luck looking. My searches were pretty nil. Maybe some threads are gone. I knew what the errors meant, but I goofed in posting the player 'name'. What I think I need is knowledge of the likely similar vehicle 'name' system. Like Flyer0 or something....hey, maybe I should try just guessing.
Its just, as I said, I can't get bf2_modtools to print a vehicle name variable, like It will player numbers.
Its just, as I said, I can't get bf2_modtools to print a vehicle name variable, like It will player numbers.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: "W.I.P." Forcing Characters into Vehicles
I thought I remember reading somewhere that to access the vehicles, you use its vehicle spawn node.
-
Ace_Azzameen_5
- Jedi

- Posts: 1119
- Joined: Sat Apr 23, 2005 8:52 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: "W.I.P." Forcing Characters into Vehicles
It works!
I don't know why, I guess its either a delayed reaction to a recent syntax change or the intricacies of my campaign mode, but it wasn't working, until mid-game, this code
slammed me inside a vulture droid.
I don't know why, I guess its either a delayed reaction to a recent syntax change or the intricacies of my campaign mode, but it wasn't working, until mid-game, this code
Code: Select all
OnCharacterSpawn(
function(player)
if IsCharacterHuman then
EnterVehicle(player, "vulturespawn1")
end
end
)
slammed me inside a vulture droid.
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: Forcing Characters into Vehicles!
Neat! What's weird is, I've tried that same code, and got nil in terms of results. Guess I must've done something wrong.
-
Ace_Azzameen_5
- Jedi

- Posts: 1119
- Joined: Sat Apr 23, 2005 8:52 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Forcing Characters into Vehicles!
I'm going to try and find out why (if its not just a syntax issue), later though, I've got life things to do.
UPDATE
Here is some code that will spawn characters right into a flyer.
OnCharacterSpawn(
function(unit)
if GetObjectTeam(GetCharacterUnit(unit)) == 1 then
print("Characters are on team 1")
if VehspawnNum == 1 then
print("Vulture 1 chosen")
EnterVehicle(unit, "Vehspawn1")
elseif VehspawnNum == 2 then
EnterVehicle(unit, "Vehspawn2")
elseif VehspawnNum == 3 then
EnterVehicle(unit, "Vehspawn3")
end
VehspawnNum = VehspawnNum + 1
end
end
UPDATE
Here is some code that will spawn characters right into a flyer.
OnCharacterSpawn(
function(unit)
if GetObjectTeam(GetCharacterUnit(unit)) == 1 then
print("Characters are on team 1")
if VehspawnNum == 1 then
print("Vulture 1 chosen")
EnterVehicle(unit, "Vehspawn1")
elseif VehspawnNum == 2 then
EnterVehicle(unit, "Vehspawn2")
elseif VehspawnNum == 3 then
EnterVehicle(unit, "Vehspawn3")
end
VehspawnNum = VehspawnNum + 1
end
end
