# Switch between montages based on selected "spell"

**URL:** <https://forums.unrealengine.com/t/switch-between-montages-based-on-selected-spell/483952>\
**Category:** C++\
**Tags:** hierarchy, unreal-engine, question, CPP, actor-class\
**Created:** [May 26, 2021, 9:40pm UTC](https://forums.unrealengine.com/t/switch-between-montages-based-on-selected-spell/483952 "2021-05-26T21:40:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pargregory](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pargregory](https://forums.unrealengine.com/u/pargregory)\
**Post date:** [May 26, 2021, 9:40pm UTC](https://forums.unrealengine.com/t/switch-between-montages-based-on-selected-spell/483952/1 "2021-05-26T21:40:59Z")

</div>

Hello,  
I am working on a prototype magic system for a later project and am facing an issue I haven’t been able to resolve. To explain, I have a parent class called ‘BaseMagic’ which is an actor and contains some setters and getters, and to create the “spells” I created child classes that added specific functionality such as projectile components etc. In the C++ file for my main character, there is an attack function that plays a montage for that attack which contains anim notifies used to call a CastSpell() funciton.  
The issue I am having is trying to switch between montages based on the spell equipped. I store the spell that should be spawned using a TSubclass but am unsure of how to implement a way to detect which type of spell is equipped and therefore which montage should be played. I have included images of code relevant to the issue. If there is a better way to try and achieve what I am doing please let me know, I am rather new to UE4, but as much as possible I want to keep it to C++. Let me know if there is any other info that would be helpful, I’ll answer the best I can.

Thanks

[Project files - Album on Imgur](https://imgur.com/a/BL9VHob) - project file links

---

<div class="post-metadata">

**Author:** ![Dream\_Powered](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dream\_Powered](https://forums.unrealengine.com/u/Dream_Powered)\
**Post date:** [May 28, 2021, 11:04am UTC](https://forums.unrealengine.com/t/switch-between-montages-based-on-selected-spell/483952/2 "2021-05-28T11:04:33Z")

</div>

i would add one or two other variable to the base magic  
either string with values like “Cast” “PrimaryAttackMedium” “BeamStart” and then when you need the info you read it

```
if(SpellSpawn->GetDefaultObject()->SpellAnimation=="PrimaryAttackMedium")
{
}
```
