I've been trying to work out how to add a component using an ability interface with lots of ability scripts, but I've been running into an issue where getting the type for AddComponent is throwing an error and I'm not sure why. I put the scripts I'm testing with for reference.
#Issue with Adding Components via an Interface
1 messages · Page 1 of 1 (latest)
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.
it would help to show the error you're getting and which line it's on
Most likely ```cs
gameObject.AddComponent(ability.GetType());
on the abilitymanager
yep that's the line
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
this is the error, im not sure how it isnt set to an instance
i guess the values are coming from those fields in abilitySet, so are you ever setting those to non-null values?