# \[UE5-0 City Sample\] How to drive AI traffic cars

**URL:** <https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE5-0, Blueprint, question\
**Created:** [April 23, 2022, 10:06pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906 "2022-04-23T22:06:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![neburas86](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neburas86](https://forums.unrealengine.com/u/neburas86)\
**Post date:** [April 23, 2022, 10:06pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/1 "2022-04-23T22:06:18Z")

</div>

In City Sample we can drive only parked cars so I’m trying to interact/drive that AI’s traffic with editing “BP\_CarEntryInteraction”, but I cant get it what value defines car is running/parked. running cars are generated completely different logic from parked?

---

<div class="post-metadata">

**Author:** ![neburas86](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neburas86](https://forums.unrealengine.com/u/neburas86)\
**Post date:** [April 24, 2022, 12:48pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/2 "2022-04-24T12:48:32Z")

</div>

Alright I found it defined with “CitySampleVehicleBase.cpp” source files

```auto
void ACitySampleVehicleBase::OnTrafficVehicleSpawned_Implementation()
{
	bIsPossessableByPlayer = false;
}

```

Changed “false” to “true”, and shipping build causes I could get in NPC’s cars. But can’t move completely and no way expect get out. Is anyone else looking into this?

---

<div class="post-metadata">

**Author:** ![mcgamez2099](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mcgamez2099/32/739225_2.png) [@mcgamez2099](https://forums.unrealengine.com/u/mcgamez2099)\
**Post date:** [January 9, 2023, 4:22pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/3 "2023-01-09T16:22:41Z")

</div>

Hi found a solution.

Edit: CitySampleMassVehicleBase.cpp

change from false to true:

```auto
void ACitySampleMassVehicleBase::PrepareForPooling_Implementation()
{
	SetActorEnableCollision(true);
}

```

edit CitySampleVehiceBase.cpp

change void ACitySampleVehicleBase::SetVehicleInputs\_Implementation(const float Throttle, const float Brake, const bool bHandBrake, const float Steering, const bool bSetSteering)

to:

```auto
void ACitySampleVehicleBase::SetVehicleInputs_Implementation(const float Throttle, const float Brake, const bool bHandBrake, const float Steering, const bool bSetSteering)
{
	
	if (bIsPossessedByPlayer)
	{}
	else
	{
		SetThrottleInput(Throttle);
		SetBrakeInput(Brake);
		SetHandbrakeInput(bHandBrake);

		if (bSetSteering)
		{
			SetSteeringInput(Steering);
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![treehousebandit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@treehousebandit](https://forums.unrealengine.com/u/treehousebandit)\
**Post date:** [October 11, 2023, 6:09pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/4 "2023-10-11T18:09:42Z")

</div>

Thank you~! The only thing I’d offer to newer people is that I needed to generate the visual studio files and rebuild the solution after following the instructions in this thread.(working in 5.1)

---

<div class="post-metadata">

**Author:** ![Jayakrishnans199](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jayakrishnans199](https://forums.unrealengine.com/u/Jayakrishnans199)\
**Post date:** [January 4, 2025, 2:40pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/5 "2025-01-04T14:40:25Z")

</div>

HI but i am not able to find these code in visual studio. I am using 5.4 version sample city project

 ![Screenshot 2025-01-04 195958](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/6/1b635fe238d6e460edf91dbd79d6422c905350a1.png)

---

<div class="post-metadata">

**Author:** ![mcgamez2099](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mcgamez2099/32/739225_2.png) [@mcgamez2099](https://forums.unrealengine.com/u/mcgamez2099)\
**Post date:** [February 24, 2025, 3:51pm UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/6 "2025-02-24T15:51:34Z")

</div>

you have to edit the cpp files and not the header files

---

<div class="post-metadata">

**Author:** ![Imaginalex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Imaginalex](https://forums.unrealengine.com/u/Imaginalex)\
**Post date:** [July 27, 2026, 4:15am UTC](https://forums.unrealengine.com/t/ue5-0-city-sample-how-to-drive-ai-traffic-cars/537906/7 "2026-07-27T04:15:25Z")

</div>

Has anyone found where and how to stop the mass traffic / pooling interface to not destroy / avoid culling and remove the entity / car from the pooling from the traffic system after possessing it ? i tried different blueprint methods and overrides and some things in cpp but i cannot seem to be able to stop the car from being part of the fragments / system that ends up despawning it suddenly after it’s too far from it’s intended spawn / traffic system.
