Download

Initializing UDamageType not working

Hi guys,

I’m trying to set UDamageType based on an what the designer picked in the editor (Out of a dropdown menu which is basically an Enum).

  1. Designer picks spell type: AOE, Projectile, etc. (Which is an ENUM under the hood)
  2. If its AOE, my FDamageEvent gets downcasted to FRadialDamage , else it remains FDamageEvent
    
  3. Designer picks elemental type such as fire or frost
    
  4. If Fire my UDamageType elementType, gets assigned to UDamageTypes_Fire::StaticClass()
    
  5. Player casts a spell, it collides with enemyPlayer
    
  6. I call enemyPlayer.TakeDamage() with the spells new values: FRadialDamageEvent and UDamageTypes_Fire (AOE Fire)
    

I have a UEANSWERHUB here with screenshots: https://answers.unrealengine.com/questions/213226/assigning-udamagetype-and-fdamageevent-dynamically.html

Mind you I can simply do this check when the spell collides with the enemy player, then cast it to lets say fire dmg. The problem with this is that I would have to recalculate the type every time the spell hit a player; whereas if I initialize it during instantiation then I would only need to do it once.

I also tried:

case EElementType::EFrost:
dynamic_cast<UDamageTypes_Frost>(elementType);
break;

case EElementType::EFrost:
elementType = new UDamageTypes_Frost();
break;

but non worked.