Hi
I like to have a gun who detect player and follow it with look at,
I do it but the problem, that the gun no follow the player properly and it change oriantion
Can you explain that to me please.
using UnityEngine;
using System.Collections;
public class ArmesEnnemies : MonoBehaviour {
public GameObject player;
public Transform targetPlayer;
// Use this for initialization
void Start () {
player = GameObject.FindGameObjectWithTag(“Player”);
}
// Update is called once per frame
void Update () {
I’m sorry, I’m a beginner.
The green object is a weapon.
I made a 90 degree rotation
But when I go to “Game” mode, it returns to its original rotation.
The glass object must follow the player.
I reuissit with “Raycast” and the object is movement but it floats.
Put an empty gameobject with your rotated barrel as a child of the empty. Look at wants to point the objects forward vecotr toward the target… your barrel’s forward appears to be one of the sides. So use the empty game object and align your barrel so it properly aligns with the empty game objects forward vector and use the look at on the empty.