Assignment 2 - Blackhole & Teleporter Projectiles
Recorded with: 5.6 | Last Update: 5.6
Preparing the Level
Place a stretched cube static mesh (can copy/paste the wall) as the floor to avoid teleporting/collision issues with the player when implementing the Teleporter projectile.
Enable Generate Overlap Events on the three boxes we previously placed to make sure the Blackhole Projectile will be able to overlap and destroy those cubes.
Blackhole Projectile
- Derive from projectile base class we create in the next lesson
- Projectile class spawned via key input (similar to MagicProjectile)
- Key binding suggestions: Right mouse button, “Q” or “F”.
-
RadialForceComponent, but using continuous ‘Force’ (Not Impulse) to pull-in Actors.
- Remember that we need to pull the object towards the component not away from the component (positive/negative force)
- You may need an absurdly high number for it to affect the cubes, think in the millions.
- Use SphereComponent to ‘Destroy’ actors on overlap (black hole)
- Must only destroy ‘simulating’ actors.
- Destroy itself after ~5 seconds (that will match the particle system duration)
- Projectile can “pass through” everything in the world, never gets stopped by other objects.
- Player should remain unaffected of pull. Ignore ‘Pawn’ collision object type on the RadialForceComponent.
- Particle Component for the black hole VFX. See asset list below.
Dash/Teleport Projectile Ability.
- Derive from projectile base class we create in the next lesson
- Projectile class spawned via input key (similar to MagicProjectile)
- Key binding suggestions: Right mouse button, “Q” or “F”.
- ‘Explodes’ after 0.2 seconds. (Timer)
- Play particle effect at point of detonation.
- Waits 0.2 seconds again (Timer) before Teleporting PlayerCharacter (aka the ‘Instigator’ of the projectile)
- Lets the detonation effect play a little bit before we teleport so player can see it.
- Make sure you ‘stop’ the projectile movement while you wait
- On hit with world: execute the same behavior (explode + teleport)
- Particles to show projectile
Assignment Assets:
- tharlevfx_tutorials/CharacterFX/ParagonSourceAssets/Niagara/..
- NS_Gideon_Ultimate
- NS_Gideon_Primary_Projectile
- NS_Portal_Teleport_Exit
- Material on the floor and wall: LevelPrototyping/Materials/MI_PrototypeGrid_TopDark
Note on Terrain/Landscape Geometry
The assignment is not using landscape which doesn't support collision 'depenetration' when using TeleportTo. That means you may fail to teleport (function returns 'false') when teleporting. Unreal Engine 5 ships with a default "Open World" level which would cause this issue. For simplicity, try this on non-landscape geometry or if you're up to the challenge, manually adjust the player's teleport destination using collision traces.
Additional Tips & Notes
Tip: EnhancedInput can easily pass in additional parameters with BindAction, and so can Timers with FTimerDelegate. Implementing the systems your own way is perfectly fine, it’s all about problem solving and exploring solutions with these assignments rather than trying to come up with the same “solution” as mine.
For the Teleporter Projectile, have a look at Actor->TeleportTo(…) rather than directly setting the Actor’s Location. (It tests collision for us to not get stuck in walls and floors)
When your source editor auto complete does not give you the expected functions on a class or component, first add the #include to your .cpp file
We missed the Abstract in the base class inside UCLASS(), you can add this to your new projectile classes.
Look at ‘Instigator’ we used for ignoring collisions, and use here for teleportation.
15 comments