Just got a quick question about the AIStimuliSourceComponent, I have written what I believe to be the regular way to create a component and set up some basic properties however I seem to have run into a problem.
I have an object in this case some metal racking and have placed a stimuli component on said racking and used the code below to set that up.
I do not get any compile errors and no crashing or anything of the kind, however, it doesn’t seem to actually register the item as the AI does not detect it. However, when I add the component inside the blueprint and set the same values in the BP editor (auto register and sense_sight) it works perfectly. I was just wondering if I’m possibly missing something important which is causing it not to work when done in C++.
The blueprint class is a child of the main C++ class so I can see the component does appear inherited in the bp editor however it’s default values are not those that I set in the following lines, they are in fact empty.
I don’t know if it is your case but I’ve had experiences in which I set a variable in c++ but it didn’t show in the editor (especially booleans), although the variable was actually set. For example, I’ve experienced setting the “SimulatePhysics” in c++ but had it unticked in the editor. When I hit play, physics were being simulated in the component.
I just checked if that could be the case now but it seems that the values still must be unchecked as they are not being detected by the AIPerceptionComponent despite it working if I checked those values in a blueprint created component. I’m also print stringing the bSuccessfullyRegistered that comes from the StimuliComponent and it is coming back as false, so it does appear that my lines of code are not actually registering the component for the sight sense at all. Still pretty stuck as far as it goes!
I am two years late, but in case anyone else had this problem (well, I’ve had it) the solution in my case was replacing the line RegisterForSense(TSubclassOf<UAISense_Sight>()) with: RegisterForSense(UAISense_Sight::StaticClass()) - the first not working one I got from book “Hands On AI in Ureal” form Packt and the other one I figuered out myself. Sometimes I wish I’d never even got into Unreal, but now it is difficult for me to drop it completely, because I’d already wasted so much time on it…