Spawning and destroying Actors

There is a Function called Spawn Actor from Class that creates an Actor instance. This Function receives the class of the Actor and the Transformation that will be applied, as input parameters. The Transformation defines the location, rotation, and scale that will be used by the new Actor. Another input parameter, called Collision Handling Override, defines how to handle the collision at the time of creation. A reference to the new instance is available in the Return Value output parameter and can be stored in a variable.

To remove an Actor instance from the Level, use the DestroyActor Function. The Target input parameter indicates which instance will be removed. The following screenshot shows an example of using the Spawn Actor from Class and DestroyActor Functions. Pressing the 1 key creates an instance of Blueprint Effect Fire using the same Transformation of the Blueprint instance that contains this script. The reference to the new Blueprint Effect Fire instance is stored in the BPFire variable. When you press the 2 key, a test is done using the Is Valid Macro to check whether the BPFire variable is referencing an instance. If the value of BPFire is None, then it is not valid. If it is valid, then it calls the DestroyActor Function that receives the BPFire variable as the Target input parameter and destroys the Blueprint Effect Fire instance that was previously created:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset