I have an actor called Brain_Turret_right that has a function. Its function is to shoot a bullet.
In my level blueprint, I want to make it so that every x amount of seconds, it calls the Brain_Turret_right’s shoot function.
How do I cast to Brain_Turret_right from the level blueprint? What object should I put in the cast node? In the example picture given, I plan to simply connect it to EventBeginPlay just to see if it works.
Have to somewhat agree with RevOverDrive in that don’t do it in the level Blueprint.
Its a trap!
My recommendation would be to have another Blueprint make reference to the turret as well as have a public variable for xSeconds on that other Blueprint. That way you place the turret on the level, place this controlling Blueprint on the level and then link them together using the exposed properties on the turret controller.
My example… …I have a Blueprint that controls the lights in a cave. CaveLightSwitchBP. It has two public variables: TriggerBox and RectLightParent. In my cave level I place an instance of CaveLightSwitchBP, a TriggerBox and at least one RectLight. Then I link everything together using the CaveLightSwitchBP public variables. The desired functionality is in CaveLightSwitchBP.
If you select the turret in your level, then go to level blueprint, right click you’ll see an option to create a reference to that actor. It will work with any actor in the level.
You could also make the “shoot every x seconds” function inside the turret blueprint and use a boolean to control if it does shoot or not per instance, that way the function will be easy to reuse in other levels.