Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how do you make a 2D object follow another 2D object in unity 2D

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FishFollow : MonoBehaviour
{
    public float Speed =;

    private Transform target;


    void Start() 
    {
        target = GameObject.FindGameObjectWithTag("Player").GetCOmponent<transform>();
    }

    void Update()
    {

        transform.position = Vector2.MoveTowards(transform.position, target.position, Speed * Time.deltaTime);
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# generate guid from hash 
Csharp :: convert-integer-to-binary-in-c-sharp 
Csharp :: remove multiple items from list c# 
Csharp :: check if an object is active unity 
Csharp :: how to check if the value is alphabet and numbers only only in c# 
Csharp :: C# setting property values through reflection with attributes 
Csharp :: unity set sprite image from script 
Csharp :: power of number 
Csharp :: c# add time to datetime 
Csharp :: blazor ref to component in if 
Csharp :: how get the user show mvc controller core 3.1 
Csharp :: if set active == false unity 
Csharp :: create new .net core project visual studio 
Csharp :: bsod screen c# 
Csharp :: if viewbag is null 
Csharp :: c# directory file 
Csharp :: c# debug writeline 
Csharp :: how to get an arrays length in c# 
Csharp :: yield in c# 
Csharp :: Raycasting to find mouseclick on Object in unity 2d games 
Csharp :: convert pdf to image c# 
Csharp :: C# api get value from header 
Csharp :: how to uncheck a radio button in c# 
Csharp :: c# remove time in datetime 
Csharp :: c# write iformfile 
Csharp :: c# structure 
Csharp :: how to see if a number is even c# 
Csharp :: remove duplicates in the list using linq 
Csharp :: select distinct linq mvc 
Csharp :: setting the parent of a transform which resides in a prefab 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =