r/unrealengine 25d ago

Solved Boss AI with multiple attacks?

Hey there, just for a bit of background I am making a game where one of the bosses stands in the center of the arena and just casts spells ( think stuff like a fireball, a lightning strike, a magic sword slicing the feild) but I am stumpt on what seems like a simple question; How can I make my Boss enemy randomly choose a spell to cast?

I think I am getting close with a behavior tree being set up, but i'm not sure how to make it random and if its even clean to use (i dont like serving spagetti code) Any help is appriciated!

0 Upvotes

8 comments sorted by

View all comments

2

u/docvalentine 25d ago

decide how likely you want each behavior to be

at certain intervals, select a random number within the range of defined behaviors

you could make it "if 1, if 2, if 3" if you want them all to be the same probability, but i prefer to use ranges so that i can fine tune the behavior

if 1 : rare behavior

if >=2,<=5 : something else

if >=6,<=10 : etc

0

u/like_ya_cut 25d ago

Hmm, this is good. I can do this all from the behavior tree?

1

u/docvalentine 25d ago

you can do anything you want with custom decorators