PlayMaker Feedback > Action Requests
BergZergArcade's "Follow" ai script to an action.
Red:
So, to anyone that's followed BergZergArcade's Hack-n-Slash tutorial should be familiar with this one...
and i've tried (and failed miserably) to make this into a custom action... so, i'm officially asking for help turning this into a custom action so that i can use it.
--- Code: ---//BergZerg Arcade helped with this one
using UnityEngine;
using System.Collections;
public class EnemyAI : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int rotationSpeed;
public int maxDistance;
private Transform myTransform;
void Awake()
{
myTransform = transform;
}
// Use this for initialization
void Start ()
{
GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
maxDistance = 2;
}
// Update is called once per frame
void Update ()
{
Debug.DrawLine(target.position, myTransform.position, Color.red);
//Looking at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position),
rotationSpeed * Time.deltaTime);
if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
//Moving to the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
}
}
--- End code ---
it works as a regular script but for the AI systems i've got to make, i need to control it much like you would with any Playmaker FSM... and it would be a lot simpler for what i need it for.
to note, i need this to be a "constantly on" action and the distance, speed and turning variables exposed so that i can control them with variables (or hard-coded in numbers.)
Alex Chouls:
If you just need to manipulate some variables on the script, the Set Property action should be enough. Search for Set Property on the forums if you need an example of how to set it up...
Red:
that doesn't do what i need it to...
is there a template or something i can use to turn this script into an action? how about a tutorial that you know of? all i need is to make that script into an action.
Red:
okay, so i found out through trial and error (manual seriously needs some serious improvement.)
Alex Chouls:
Sorry, yeah the API docs need some work. Unfortunately they tend to slip in priority since we ship with hundreds of examples showing how to build actions, so normally you should be able to find an existing action as a starting point...
I'll try to add some high level pointers to the docs.
Are there particular things that you figured out that you'd like to see highlighted?
Navigation
[0] Message Index
[#] Next page
Go to full version