Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D camerafollow

Discussion in '2D' started by gpollak450, Jun 14, 2015.

  1. gpollak450

    gpollak450

    Joined:
    Jun 14, 2015
    Posts:
    7
    Hi im new to unity and im creating my first game im almost done I just need the camera to follow the player. I've been tinkering around with my script and i dont know what is the problem. Do I need to just put in some values? Here's my code I got it from here: http://forum.brackeys.com/thread/camera-2d-follow-the-player/


    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. public class PlayerCam: MonoBehaviour {
    5.     public Transform player;
    6.     void Update ()
    7.     {
    8.         transform.position = new Vector3 (player.position.x + 7, 3, -20);
    9.         transform.position = new Vector3(player.position.x + 7, player.position.y + yOffset, -20);
    10.     }
    11. }
     
    Last edited: Jun 15, 2015
  2. Gardes

    Gardes

    Joined:
    Apr 7, 2015
    Posts:
    46
    How could you be almost done, while you have no clue of C#? Did you copy pasted all what you've found? And will you ask tommorow for the next code and we will programming your game? Im realy wondering. o_O

    If you want to make games, learn the specific language and finally try something. There are TONS of tutorials.
    If you land in errors, I realy like to help, but this time, I only have this link for you.

    Lot's of scripts and tutorials about camera follow
     
    theANMATOR2b and BusyCat like this.
  3. AaronLeigh

    AaronLeigh

    Joined:
    Jun 16, 2015
    Posts:
    1
    I agree with Gardes. It would be a lot better for you in the short and long run to learn the language. Asking someone for their opinion when you're experimenting and practicing code is fine, but asking someone to basically finish your scripts for you is not good, and doesn't help you at all. Also if you infact have been copy-pasting all your code up until now, you should halt that as soon as possible. Copy-pasting is very bad practice when it comes to programming.
     
  4. gpollak450

    gpollak450

    Joined:
    Jun 14, 2015
    Posts:
    7
    Thanks really helped but i have been tinkering around with the code.