Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Rotate a cloned object with key press

$
0
0
I'm trying to rotate a cloned object once it is spawned but i'm having difficulty and cant find any information about how to do this. For example, i spawn a wall, once i press "R" it rotates to 90 degrees along its x axis. Or, if you press "R" it transforms to 90 and then you put it down? I just need an understanding on how to do this. I'm unfamiliar with Quaternions is this the problem?? The code i have doesn't seem to be working. if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // Storage point for the Ray RaycastHit hit; if (Physics.Raycast(ray, out hit)) { // Assigning the point its variable endPoint = hit.point; GameObject clone; // Clone the objects and spawn them in the game 'world' clone = Instantiate(items[i], endPoint, items[i].transform.rotation) as GameObject; if (Input.GetKey(KeyCode.R)) { clone.transform.Rotate(0, 90, 0); Debug.Log("Rotating Object"); } } }

Viewing all articles
Browse latest Browse all 508

Trending Articles



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