- Home /
 
 
               Question by 
               $$anonymous$$ · Aug 02, 2014 at 03:11 PM · 
                lookatupright  
              
 
              I want a GameObject to keep looking at player, but remaining upright
I want a blade of grass to keep looking at the player, but so that it'll remain upright. I've searched everywhere, but all I found is help with rigibodies. It isn't a rigidbody.
This is what I have so far (CSharp):
 using UnityEngine;
 using System.Collections;
 
 public class muru_vaatamine : MonoBehaviour {
 
     GameObject player;
 
     void Start ()
     {
         player = GameObject.FindWithTag ("Player");
     }
 
     void Update ()
     {
         transform.LookAt (player.transform);
     }
 }
 
              
               Comment
              
 
               
              Answer by robertbu · Aug 02, 2014 at 03:12 PM
Try this:
 void Update ()
 {
     Vector3.pos = player.transform;
     pos.y = transform.y;
     transform.LookAt (pos);
 }
 
              Your answer
 
             Follow this Question
Related Questions
Make an FPS gun point at the mouse position. 2 Answers
LookAt but using physics AddRelativeTorque 1 Answer
Lookat mouse, without raycasting? 1 Answer
How to send vars! 1 Answer
Autorotation to tween gameobject 0 Answers