D
D
Deathgar2017-02-15 20:55:31
Programming
Deathgar, 2017-02-15 20:55:31

Character focus, how right?

I decided to remember the past, I tried to quickly focus the object. It focuses, but when I press play, the camera stops showing objects, just a blank screen.


-Do you see the sprites?
-Not.
-And I. And they are.

public class Focuse : MonoBehaviour {
  public GameObject pers;
  public float y = 1f;
  // Use this for initialization
  void Start () {
    Vector3 temp = pers.transform.position;
    temp.y += y;
    transform.position = temp;
  }
  
  // Update is called once per frame
  void Update () {
    Vector3 temp = pers.transform.position;
    temp.y += y;
    transform.position = temp;
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2017-02-15
@Deathgar

I tried to understand what your script should do, but did not understand. What is "character focus" in human terms? What is this script on?
In fact, you take the coordinates of the pers object, and give the object on which the script hangs the same coordinates with height adjustment. But at least kill me I don’t understand - why? Yes, even in the update. Do you just need to position the object higher? Do this in the hierarchy and that's all - put this GO as a child of your pers and set the necessary coordinates for it - there will be an automatic binding without any scripts.
And the blank screen is most likely because there is nothing in the camera's field of view.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question