hello
I have windmills that when i press the mouse it spawns an windmill at that location. What i want to do is when i press the windmill with the mouse again i can rotate the windmill with the arrow keys but how do i do that.
I have this script for instantiation.
Can someone help me?
using UnityEngine;
using System.Collections;
public class windmolenmuis : MonoBehaviour
{
public GameObject windmolen;
public bool windmolenplaatsen = false;
void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
windmolenplaatsen = !windmolenplaatsen;
}
Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
if (Input.GetMouseButtonDown(0))
{
if (windmolenplaatsen == true)
{
Vector3 wordPos;
Ray ray = Camera.main.ScreenPointToRay(mousePos);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000f))
{
wordPos = hit.point;
}
else
{
wordPos = Camera.main.ScreenToWorldPoint(mousePos);
}
Instantiate(windmolen, wordPos, Quaternion.identity);
//or for tandom rotarion use Quaternion.LookRotation(Random.insideUnitSphere)
}
}
}
void OnGUI()
{
if (windmolenplaatsen == false)
{
GUI.Box(new Rect(100, 0, 130, 50), "windmolen draaien");
}
if (windmolenplaatsen == true)
{
GUI.Box(new Rect(100, 0, 130, 50), "windmolen plaatsen");
}
}
}