Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: jrush64 on April 15, 2016, 08:20:39 AM
-
Hi,
So I've tried using both the add a component and destroy component actions but neither seem to work.
I'm trying to add a script at runtime but it doesn't work.
-
Hi,
Would disabling a script and enabling it at runtime do the trick?
If so drag the script component from the gameobject's inspector into the action list of the state that should control the enabling.
When you drop the script component a small menu will appear, choose 'set property'.
In the set property action that has now appeared choose enable, then tick or untick the enable box as needed.
Good luck with it. I hope this helps you achieve what you are trying to do and let us know how it goes.
-
Disabling won't do. Basically i'm having an animation issue with the third person controller I'm using.
I need to destroy the script for the animation to work properly then add it again when the animation is finished playing.
-
I just tested both actions here and they seem to be working fine.
Do you get an error in the console?
If the script is in a namespace, make sure you add the namespace to the script name. (e.g., MyNamespace.MyScriptName).
-
I get this error.
"AddComponent : Can't add component: AnimatorMonitor"
-
Is AnimatorMonitor in a namespace?
Can you post the source code for AnimatorMonitor?
-
I'm not sure... Its from third person controller by opsive. I'm not sure if I can post the full source code but I can probably post the top part of the script.
using UnityEngine;
#if ENABLE_MULTIPLAYER
using UnityEngine.Networking;
#endif
using System.Collections.Generic;
using Opsive.ThirdPersonController.Abilities;
namespace Opsive.ThirdPersonController
{
/// <summary>
/// Added to the same GameObject as the Animator, the AnimationMonitor will control the trigger based Animator and translate mecanim events to the event system used by the Third Person Controller.
/// </summary>
#if ENABLE_MULTIPLAYER
public class AnimatorMonitor : NetworkBehaviour
#else
public class AnimatorMonitor : MonoBehaviour
#endif
{
If that doesn't help, then I can send you the script by PM.
-
Use "Opsive.ThirdPersonController.AnimatorMonitor" as the name of the script.
Unfortunately the script popup doesn't include the namespace right now, so you have to add it manually.
-
Ok that worked. Thank you.
-
Cool. The next update improves the script selection menus so they include namespaces...