Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Zombie : MonoBehaviour {
- [SerializeField]
- private Rigidbody2D zombieRB;
- [SerializeField]
- private AStar aStar;
- public float speed = 0.005f;
- Vector3 nextNodePosition;
- // Update is called once per frame
- void Awake()
- {
- nextNodePosition = new Vector3(0, 0, 0);
- zombieRB = GetComponent<Rigidbody2D>();
- aStar = GetComponent<AStar>();
- //zombieRB.AddForce(zombieRB.transform.up * 8.2f);
- }
- void FixedUpdate()
- {
- }
- void Update()
- {
- if (Input.GetKeyDown("m"))
- {
- }
- GetNextNodePos(ref nextNodePosition);
- float step = speed * Time.deltaTime;
- transform.position = Vector3.MoveTowards(transform.position, nextNodePosition, step);
- }
- private void GetNextNodePos(ref Vector3 nextNodePosition)
- {
- if (aStar.isRunning)
- {
- nextNodePosition = aStar.nextNode.transform.position;
- }
- }
- }
Add Comment
Please, Sign In to add comment