[1.1.72] If 2 car entities are on top of each other the player can't get out
Posted: Thu Nov 17, 2022 9:51 pm
When 2 cars are created on top of each other and the player is driving one of them things go a bit odd when trying to leave. I appreciate this is an odd situation, but encountered when modding and swapping a vehicle a player was in for another one and wanting to eject the player during this process.
If the player tries to leave the car by pressing "enter" they are unable too. Effectively stuck inside their vehicle. Same if you use a script to set the player to not be driving.
If you kick the player out via script from the car by setting the driver to nil the player is placed inside the collision box of the car.
If the player tries to leave the car by pressing "enter" they are unable too. Effectively stuck inside their vehicle. Same if you use a script to set the player to not be driving.
Code: Select all
/sc
local character = game.player.character
local surface = character.surface
local carPosition = {10,10}
local car1 = surface.create_entity({ name = "car", position = carPosition, force = character.force, create_build_effect_smoke = false, raise_built = true })
car1.set_driver(character)
--[[ Without car2 this places the player normally --]]
local car2 = surface.create_entity({ name = "car", position = carPosition, force = character.force, create_build_effect_smoke = false, raise_built = true })
game.player.driving = false
If you kick the player out via script from the car by setting the driver to nil the player is placed inside the collision box of the car.
Code: Select all
/sc
local character = game.player.character
local surface = character.surface
local carPosition = {10,10}
local car1 = surface.create_entity({ name = "car", position = carPosition, force = character.force, create_build_effect_smoke = false, raise_built = true })
car1.set_driver(character)
--[[ Without car2 this places the player normally --]]
local car2 = surface.create_entity({ name = "car", position = carPosition, force = character.force, create_build_effect_smoke = false, raise_built = true })
car1.set_driver(nil)