Ability preset not keeping target

nathh

New member
Hey, I have this RotateTowards ability preset that sets the target to a game object that is parented to my player, which is placed in the scene (player is also is a prefab, for what its worth).

rotate.png

Problem is, the target field seems to go blank every time I close and reopen the project. I have to assign it to the game object again.

Any reason why this is happening?
 
Presets are stored in at the project level so they cannot reference scene objects. That property should not be listed within the preset so I'll mark it as non serialized for the next update. You will need to set the target through script at runtime.
 
Hey Justin, how would I go about setting the target at runtime? Haven't been able to find a code example in the documentation.
 
Something like this:

C#:
UltimateCharacterLocomotion locomotion; // get a reference to the character's UltimateCharacterLocomotion component, e.g. by setting it in the inspector
Transform target; // the desired target transform
RotateTowards rotateTowards;

...

rotateTowards = locomotion.GetAbility<RotateTowards>(); // get the ability
rotateTowards.Target = target // set the target
 
Top