playMaker

Author Topic: Get variable from script [SOLVED]  (Read 707 times)

TrueSoSense

  • Playmaker Newbie
  • *
  • Posts: 17
Get variable from script [SOLVED]
« on: January 16, 2022, 01:22:10 PM »
Hello ! I wanted to implement turning animations to my NavMesh AI using a blend tree, i couldn't achieve this. On a Unity forum post i found a script that basically gets the rotation speed and the speed.

Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AngularVelocity : MonoBehaviour
{
    [SerializeField] float speed;
    [SerializeField] float turn;

    // Update is called once per frame
    void Update()
    {
        var mAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
        Vector3 s = mAgent.transform.InverseTransformDirection(mAgent.velocity).normalized;
        speed = s.z;
        turn = s.x;
    }
}


I edited it a little bit. I want to change the animator floats by using Playmaker.
I tried to use "GetProperty", but there are no options for variables.
The only options are : Enable, HideFlags, IsActiveAndEnbaled, RunInEditMode, UseGUILayout and Name > String, Length.

Can someone help me ?
PS : It's my first post so if there are any errors, please tell me.
« Last Edit: January 17, 2022, 02:23:45 PM by TrueSoSense »

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
Re: Get variable from script
« Reply #1 on: January 17, 2022, 08:05:17 AM »
Get property will show public variables.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Get variable from script
« Reply #2 on: January 17, 2022, 09:50:24 AM »
Hi.
I made a custom action for it.
I have not tested but it should work, let me know if it works.

TrueSoSense

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Get variable from script
« Reply #3 on: January 17, 2022, 02:22:23 PM »
Thanks your custom action actually works ! I have been searching an action like that one for months ! Thank you very much.