Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
How to Get Gameobject position on screen resolution that not passed the resolution to set

I got an object at the screen. At the beginning it is located at x=0,y=0,z=0 later it moves to a different position. I just want to make sure that this object does not move to locations invisible to the user (it's the player main character itself and I neither want the player to be able to go back from his current location nor going forward the camera following him).

Can you explain to me what I need to do here?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I think you're asking:

If a player-character on the screen is moving around, you want the person sitting at the computer to be able to see it always. To do this you need to set up the camera to follow this object.

Here are some links that may get you started:

http://unity3d.com/support/documentation/Components/class-Camera.html

http://unity3d.com/support/documentation/ScriptReference/Camera.html

over 4 years ago · Santiago Trujillo Report

0

This tutorial has an example of how to implement a camera that follows the player.

http://unity3d.com/support/resources/tutorials/3d-platform-game.html

over 4 years ago · Santiago Trujillo Report

0

using UnityEngine;
using System.Collections;

public class NewGameScript : MonoBehaviour 
{
    float t=0f;
    float v=20f;
    float dist;
    // Use this for initialization
    void Start ()
    {

    }

    void Update () 
    {

        if(Input.GetKeyUp("up"))
        {
            if(t<0.1)
            {
                t +=Time.deltaTime*0.07f;
            }
            dist=t*v*0.5f;
            gameObject.transform.position +=transform.forward*dist;                   
        }
        else if(Input.GetKeyUp("down"))
        {
            if(t>-0.1)
            {
                t -=Time.deltaTime*0.07f;
            }
            dist=t*v*0.5f;
            gameObject.transform.position +=transform.forward*dist;
        }   
        else if(Input.GetKey("left"))
        {   
            transform.Rotate(0,-0.9f*(dist+1), 0);
            gameObject.transform.position +=transform.forward*0.1f*(dist+1);
        }   
        else if(Input.GetKey("right"))
        {
            transform.Rotate( 0,0.9f*(dist+1),0);
            gameObject.transform.position +=transform.forward*0.1f*(dist+1);
        }
    }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!