Hello, I am making an FPS shooter game, with a little sphere named Bullet. I want Bullet to go to the current position of the character which is named char_shadow. I tried using this script but it would not work. Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class scriptforsphere : MonoBehaviour { GameObject char_shadow; // Use this for initialization void Start () { } float speed; // Update is called once per frame void Update () { float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, char_shadow.transform.position, step); } }
try changing 'float speed' to 'public float speed' and setting a value greater than 0 from the inspector.
Helps? before it would have been zero, so never move. What is happening? Explain more beyond it doesn't work, please. Do you have any errors?
char_shadow is private and never set as well... which visual studio would be warning you of. https://unity3d.com/learn/tutorials