Quantcast
Channel: Questions in topic: "gui"
Viewing all articles
Browse latest Browse all 125

How to unable player to move on GUI buttons

$
0
0
Hello Guys ! I cant solve problem with GUI and player movment. When my character level up, i can click on button to increase damage or health. But, when i click on this button he moves to location behind button. How can i fix that ? I make buttons by GUI.Button and use texture/Rect. There is my mouse script : void Update() { cursorPosition(); if (!attack && !die) { if (Input.GetMouseButton(0)) { FindPosition(); } MoveToPosition(); } } void FindPosition() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit, 1000)) { if (hit.collider.tag != "AllyMob" && hit.collider.tag != "Enemy") { position = new Vector3(hit.point.x, hit.point.y, hit.point.z); } } } public void cursorPosition() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000)) { mouseposition = hit.point; } } void MoveToPosition() { if (Vector3.Distance(transform.position, position) > 2.2) { Quaternion Rotation = Quaternion.LookRotation(position - transform.position); Rotation.x = 0f; Rotation.z = 0f; transform.rotation = Quaternion.Slerp(transform.rotation, Rotation, Time.deltaTime * 10); controller.SimpleMove(transform.forward * speed); GetComponent().CrossFade(run.name); } else { GetComponent().CrossFade(idle.name); } }

Viewing all articles
Browse latest Browse all 125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>