Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Character RigidBody2D
- body type: dynamic
- material None
- simualted yes
- use automass no
- mass 1
- linear drag 0
- Angular Drag 0.05
- Gravity Scale 0
- Cloosiion detection discrete
- start awake
- interpolation none
- Player Movement Script
- Script PlayerMovement
- MoveSpeed 5
- rb Character Rigidbody2d
- Character must have Player tag
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyFollow : MonoBehaviour {
- public float speed;
- public float stoppingDistance;
- private Transform target
- void Start () {
- target = GameObject.FindObjectWithTag("Player").GetComponent<Transform>();
- }
- void Update () {
- if(Vector2.Distance(transform.position, target.position) > StoppingDistance){
- transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement