Answer the question
In order to leave comments, you need to log in
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
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;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question