How do I make create a rotateable object that follows a raycast hit point?

So I have created a script detecting the point where the raycast hits, and I have been able to instantiate a prefab to that point, but all I wish to do is to be able to rotate this on both the X and the Y axis, as the object that is going to repeadetly spawn/despawn is rotated 90 degrees on the wrong axis. And I also want to be able to rotate it on the Y axis so that I can later on place it.

Any ideas how I can change the rotation of the Quartenion?

Small gif of how it works right now: Recordit: Record screencasts fast & free! with GIF Support!

Code used:

var rotation = Quaternion.identity;
Instantiate(bScript.shelterPrefabMarker, hit.point, rotation);

in the update function.

I wouldn’t suggest changing the Quaternion, cuz messing around with Quaternion is just not a good idea unless you understand it.

What you can do is the following:

var temp : GameObject = Instantiate(bScript.shelterPrefabMarker, hit.point, Quaternion.identity) as GameObject;

temp.transform.rotate(90,90,90); //rotate your gameObject

I am not too familiar with javascript syntax, but basically you grab the gameObject that will be spawned with type casting, and then rotate the object.

If anyone else stumbles upon this, this is how I solved it (C#):

tmp.transform.position = hit.point;

if (Input.GetKey(KeyCode.Q))
     tmp.transform.Rotate(0, -rotationSpeed * Time.deltaTime, 0);

else if (Input.GetKey(KeyCode.E))
     tmp.transform.Rotate(0, rotationSpeed * Time.deltaTime, 0);