Z
Z
Zimaell2020-05-21 12:44:03
Unity
Zimaell, 2020-05-21 12:44:03

How to make a static object?

I have a movable area (back, it can be moved with a finger / mouse), on this area there are objects that move with this area, but I need to place a static menu that should always be on the left side of the screen and not move in any way, how to do this?
Here is the area movement script

spoiler
public class CameraControl : MonoBehaviour {
  Vector3 hit_position = Vector3.zero;
  Vector3 current_position = Vector3.zero;
  Vector3 camera_position = Vector3.zero;
  void Update(){
    if(Input.GetMouseButtonDown(0)){
      hit_position = Input.mousePosition;
      camera_position = transform.position;
      }
    if(Input.GetMouseButton(0)){
      current_position = Input.mousePosition;
      current_position.z = hit_position.z = camera_position.y;
      Vector3 direction = Camera.main.ScreenToWorldPoint(current_position) - Camera.main.ScreenToWorldPoint(hit_position);
      direction = direction * -1;
      Vector3 position = camera_position + direction;
      transform.position = position;      
      }
    }
  }

And then everything that I put on the stage moves with the camera ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alfaruh, 2020-05-21
@Alfaruh

If I understand you correctly, then you should read about Unity UI - https://docs.unity3d.com/Packages/[email protected]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question