Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So, basicly I want to do something, but it doesn't work. I wanna reference a GameObjekt, but don't know how. I want to make "player" the same as "vehicle" is that possible? or make that "player" means "vehicle"

Here's my code:

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

public class FollowPlayer : MonoBehaviour
{     
    public Gameobjekt player;

    // Start is called before the first frame update
    void Start()
    {
       GameObjekt.find(Vehicle)
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = player.transform.position; 
    }
}


What I have tried:

Googling and trying stuff myself.
Posted
Updated 11-Jul-22 7:40am

It's "GameObject"; not GameObjekt.

Unity - Manual: Important Classes - GameObject[^]
 
Share this answer
 
Your code snippet does not seem to make any sense.
Please have a look at their documentation:
Unity - Scripting API: GameObject.Find[^]
There is even a tutorial!
Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn[^]
 
Share this answer
 
I think you probably need to do two things:
1) Learn C# and how it works pretty well before you start with Unity development - y6our question shows that you don't understand objects, instances, or inheritance at all, and you need to know that stuff before you start anything complex. There are many good books on the subject - Wrox, Addison Wesley, and MS Press all do excellent volumes.

2) Learn Unity: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900