void Start()
    {
        // Aim Constraint
        aimConstraint = gameObject.GetComponent <AimConstraint>();
        aController   = GetComponent <Animator>();
        ConstraintSource cc = new ConstraintSource();

        cc.sourceTransform = lookAtObject.transform;
        cc.weight          = 1.0f;
        aimConstraint.AddSource(cc);
        aimConstraint.rotationAxis = Axis.Y | Axis.Z;
        // Aim Constraint

        // populating waypoints
        foreach (Transform i in GameObject.Find("targets").GetComponentsInChildren <Transform>())
        {
            targets.Add(i);
        }
        targets.RemoveAt(0); // done populating waypoints

        agent = GetComponent <NavMeshAgent>();
        StartCoroutine("AnimationState");
        NextTarget();
        GotoTargetIndex();
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     target = GameObject.FindGameObjectWithTag("SoulTarget1");
     aimC   = GetComponent <AimConstraint>();
     conS.sourceTransform = target.transform;
     conS.weight          = 1;
     aimC.SetSource(0, conS);
     soulC      = GameObject.FindGameObjectWithTag("SoulTarget1").GetComponent <SoulCounter>();
     soulParSys = GetComponentInChildren <ParticleSystem>();
 }
示例#3
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     cameraControl      = animator.GetComponent <CameraControl>();
     targetFocus        = cameraControl.targetFocus;
     positionConstraint = animator.GetComponent <PositionConstraint>();
     aimConstraint      = animator.GetComponent <AimConstraint>();
     positionConstraint.constraintActive = false;
     gameObjectTransform = animator.gameObject.transform;
     targetPosition      = targetFocus.position + offsetFocus;
 }
示例#4
0
 // Use this for initialization
 void Start()
 {
     myCamera      = GetComponent <Camera>();
     myAim         = GetComponent <AimConstraint>();
     myAim.enabled = true;
     if (!playerRigidbody)
     {
         playerRigidbody = GetComponentInParent <Rigidbody2D>();
     }
 }
示例#5
0
 // Start is called before the first frame update
 void Start()
 {
     target = GameObject.FindGameObjectWithTag("SoulTarget"); //define o alvo
     aimC   = GetComponent <AimConstraint>();
     conS.sourceTransform = target.transform;                 //define o alvo como fonte do constraint
     conS.weight          = 1;                                //peso do constraint
     aimC.SetSource(0, conS);                                 //adiciona o constraint
     soulC      = GameObject.FindGameObjectWithTag("SoulTarget").GetComponent <SoulCounter>();
     soulParSys = GetComponentInChildren <ParticleSystem>();
 }
示例#6
0
 private void Awake()
 {
     anim    = GetComponent <Animator>();
     agent   = GetComponent <NavMeshAgent>();
     mat     = mRender.material;
     rb      = GetComponent <Rigidbody>();
     aim     = GetComponent <AimConstraint>();
     mr      = GetComponent <MeshRenderer>();
     col     = new Color(1, 1, 1, 1);
     colV    = 1;
     esperaF = 1;
 }
示例#7
0
    void Awake()
    {
        canDoAction = true;

        laser = GetComponentInChildren <LineRenderer>();
        if (laser)
        {
            laserPoints   = laser.positionCount;
            laser.enabled = false;
        }

        aim       = GetComponentInChildren <AimConstraint>();
        aimWeight = aim.weight;
    }
示例#8
0
    /// <summary>
    /// Process a property for an aimConstraint
    /// </summary>
    /// <param name="go">
    /// A <see cref="GameObject"/>
    /// </param>
    /// <param name="nodeName">
    /// A <see cref="System.String"/>
    /// </param>
    /// <param name="attributeName">
    /// A <see cref="System.String"/>
    /// </param>
    /// <param name="val">
    /// A <see cref="System.Object"/>
    /// </param>
    void ProcessAimConstraintProperty(GameObject go, string nodeName, string attributeName, System.Object val)
    {
        AimConstraint node = GetMayaNodeOnGameObject(nodeName, typeof(AimConstraint), go) as AimConstraint;

        node.constrainedObject = go.transform;
        switch (attributeName)
        {
        case "offset":
            node.offset = (Vector4)val;
            break;

        case "aimVector":
            node.aimVector = (Vector4)val;
            break;

        case "upVector":
            node.upVector = (Vector4)val;
            break;

        case "worldUpVector":
            node.worldUpVector = (Vector4)val;
            break;

        case "worldUpMatrix":
            node.worldUpObjectName = val as string;
            break;

        case "worldUpType":
            node.worldUpType = (AimConstraint.WorldUpType) int.Parse(val as string);
            break;

        default:
            if (IsConstraintWeightAttribute(attributeName))
            {
                node.InsertTargetUsingWeightAttribute(attributeName, (float)val);
            }
            if (IsConstraintTargetAttribute(attributeName))
            {
                node.InsertTargetUsingTargetAttribute(attributeName, val as string);
            }
            break;
        }
    }
示例#9
0
 void Start()
 {
     Stats();
     if (state == State.SandWorm || state == State.ArmoredSandWorm)
     {
         trAimClone = Instantiate(trAim, transform.position, Quaternion.identity);
         ac         = trAimClone.GetComponent <AimConstraint>();
         ac.AddSource(pl);
     }
     else
     {
         ac = gameObject.GetComponent <AimConstraint>();
         ac.AddSource(pl);
     }
     player             = GameObject.FindWithTag("Player");
     pl.sourceTransform = player.transform;
     pl.weight          = 1;
     ac.AddSource(pl);
     slowTime = 3;
 }
示例#10
0
        public override void ToolGUI(SceneView view, Vector3 handlePosition, bool isStatic)
        {
            TransformManipulator.BeginManipulationHandling(false);
            EditorGUI.BeginChangeCheck();
            Quaternion    rotation  = Tools.handleRotation;
            AimConstraint component = Selection.activeTransform.GetComponent <AimConstraint>();

            if (component != null && component.constraintActive)
            {
                rotation = TransformManipulator.mouseDownHandleRotation;
            }
            Vector3 vector = Handles.PositionHandle(handlePosition, rotation);

            if (EditorGUI.EndChangeCheck() && !isStatic && TransformManipulator.HandleHasMoved(vector))
            {
                ManipulationToolUtility.SetMinDragDifferenceForPos(handlePosition);
                if (Tools.vertexDragging)
                {
                    ManipulationToolUtility.DisableMinDragDifference();
                }
                TransformManipulator.SetPositionDelta(vector, TransformManipulator.mouseDownHandlePosition);
            }
            TransformManipulator.EndManipulationHandling();
        }
 public static Tween TweenWeight(this AimConstraint constraint, float to, float duration) =>
 Tweening.To(getter: () => constraint.weight,
             setter: weight => constraint.weight = weight,
             to, duration).SetTarget(constraint);
 public static Tween TweenRotationAtRest(this AimConstraint constraint, Vector3 to, float duration) =>
 Tweening.To(getter: () => constraint.rotationAtRest,
             setter: rotationAtRest => constraint.rotationAtRest = rotationAtRest,
             to, duration).SetTarget(constraint);
 public static Tween TweenAimVector(this AimConstraint constraint, Vector3 to, float duration) =>
 Tweening.To(getter: () => constraint.aimVector,
             setter: aimVector => constraint.aimVector = aimVector,
             to, duration).SetTarget(constraint);