Modify AIPerception Sight Range at runtime [4.7.6]

I’m trying to manipulate my AI’s vision radius at game time. This could be caused by a buff, upgrade or pickup. As it stands I see a get Sight Radius but not a set. Am I missing something or is it just not available until 4.8 (or maybe later)

It’s not doable via blueprints at this point, but I’ll file a feature request and try to squeeze it in for 4.9

Cheers,

–mieszko

Hope to see this included too. :wink: Trying to have relaxed guards moving around their fireplace camp and not see player from far. While in firefights the range need to be doubled or more.

Edit: Actually could just add own distance check. But official solution could be nice too.

Hi mieszko

Was this option ever add to the BP ver ?

Thanks

Any update on this one?

Thanks!

You can do it in C++ quite easily

	FAISenseID Id = UAISense::GetSenseID(UAISense_Sight::StaticClass());

	if (!Id.IsValid())
	{
		UE_LOG(LogTemp, Error, TEXT("Wrong Sense ID"));
		return;
	}

	// GetPerception() = AIController->GetPerceptionComponent()
	auto Config = GetPerception()->GetSenseConfig(Id);

	if (Config == nullptr)
		return;

	auto ConfigSight = Cast<UAISenseConfig_Sight>(Config);

	// Save original lose range
	float LoseRange = ConfigSight->LoseSightRadius - ConfigSight->SightRadius;
	
	ConfigSight->SightRadius = NewRange;

	// Apply lose range to new radius of the sight
	ConfigSight->LoseSightRadius = ConfigSight->SightRadius + LoseRange;

	GetPerception()->RequestStimuliListenerUpdate();

Thanks for this code snippet, this made things quite easy to expose the functionality for blueprints!

It’d be nice to update the arc as well, for animations that have a creature looking around. Any chance on something like this being added as well?

I too would like word on this if it’s possible to do in blueprint yet. My player gets larger after a certain point and I want the AI to act accordingly since the player’s 2d orthogonal camera width is x2.

PS: I don’t know C++ and have been using blueprint for my simplistic 2D project. I hope that with time becoming proficient in blueprint will help me understand some of the fundamentals of coding in C++. (Before I started I didn’t even know what a boolean was).

3 years…and 12 versions later. Got this squeezed in yet?

.+1 year still waiting…

286835-skel.png

+1, there are several basic things on perception that really need to be exposed in BP. The fact that you cant set who is neutral, enemy ect. makes perception pretty much useless when you use many characters in a scene because perception kill performance if it detects everyone…

In generel i would love to see a place where us blueprinters could request exposure of variables and functions. I would happily put 20USD in the pot for these exposures and im not alone. So when a pot is big enougth to expose something then any CPP programmer could simply add the request for the next engine release and take the pot.

lmao how is this still not done…

I guess still nothing?