#Issue with Adding Components via an Interface

1 messages · Page 1 of 1 (latest)

pastel hollow
gloomy kettle
#

You cant add a mono from an interfacetype

#

Best I can think of is to check against the type and then add the specific class as component. But maybe there is a more elegant way.

frigid lance
#

it would help to show the error you're getting and which line it's on

gloomy kettle
#

Most likely ```cs
gameObject.AddComponent(ability.GetType());

on the abilitymanager
frigid lance
#

well, what's the error? ability must have some type that isn't AbilityInterface

#

if the values you're passing in are instances of component types i don't see why that wouldn't work

pastel hollow
frigid lance
#

i guess the values are coming from those fields in abilitySet, so are you ever setting those to non-null values?

pastel hollow
#

i think i might've noticed the error, i never set gunScript to anything in the ability manager

#

so everything in abilitySet is null