Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. Character RigidBody2D
  3. body type: dynamic
  4. material None
  5. simualted yes
  6. use automass no
  7. mass 1
  8. linear drag 0
  9. Angular Drag 0.05
  10. Gravity Scale 0
  11. Cloosiion detection discrete
  12. start awake
  13. interpolation none
  14.  
  15. Player Movement Script
  16. Script PlayerMovement
  17. MoveSpeed 5
  18. rb Character Rigidbody2d
  19.  
  20. Character must have Player tag
  21.  
  22. using System.Collections;
  23. using System.Collections.Generic;
  24. using UnityEngine;
  25.  
  26. public class EnemyFollow : MonoBehaviour {
  27.  
  28.  
  29. public float speed;
  30. public float stoppingDistance;
  31.  
  32. private Transform target
  33.  
  34. void Start () {
  35. target = GameObject.FindObjectWithTag("Player").GetComponent<Transform>();
  36. }
  37.  
  38. void Update () {
  39.  
  40. if(Vector2.Distance(transform.position, target.position) > StoppingDistance){
  41. transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement