- Home /
This question was
closed Apr 04, 2014 at 03:59 PM by
PvTGreg for the following reason:
The question is answered, right answer was accepted
Question by
PvTGreg · Apr 04, 2014 at 08:22 AM ·
rotationscrollwheel
rotating object
ok instead of opening another question how do i make the initiated object follow the rotationg as well? also how do i get it to work with scroll wheel if anyone can help me
var player : Transform;
var ActualPlacedPeice : Transform;
function Start()
{
//transform.eulerAngles.y = 0;
player = GameObject.Find("Player").transform;
}
function Update ()
{
var pos = player.position + player.forward * 5.0;
transform.position = pos + Vector3.up;// * 0.5;
transform.rotation = Quaternion.LookRotation(player.transform.forward);
var hit : RaycastHit;
if (Physics.Raycast(transform.position, Vector3.down, hit))
{
transform.position = hit.point + Vector3.up * 0.5;
}
if (Input.GetButtonDown("Fire1"))
{
Instantiate(ActualPlacedPeice,transform.position, transform.rotation);
}
if (Input.GetButton("Fire2"))
{
// transform.eulerAngles.y += 90;
transform.Rotate(0,90,0);
}
}
Comment
Answer by Fappp · Apr 04, 2014 at 09:12 AM
Ah yeah, I got really frustrated on this one too once! Fixed it by adding this to the Start function:
transform.eulerAngles.y = 0;
Also change this:
transform.Rotate(0,90,0);
To this:
transform.eulerAngles.y += 90;
hope it works for you!
any idea how i can make it so the object being spawned is places in the same rotation as the object?