Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda