Question by
romainover974 · Mar 18, 2018 at 09:01 PM ·
movement scriptmovements
Object don't move towards.
I created a simple script to move bullet but when the bullet instantiate they froze in air and they kind of glitch like they want to move but don't.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletScript : MonoBehaviour {
public Vector3 StartPos;
public Vector3 EndPos;
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(StartPos, EndPos, step);
}
}
The Vector is comming from another script here is a sample :
![GameObject BInstance = Instantiate(Bullet, gunEnd.position, transform.rotation);
BInstance.GetComponent<BulletScript>().StartPos = gunEnd.position;
BInstance.GetComponent<BulletScript>().EndPos = hit.point;][1]
And as you can see from the image the bullet stay frozen in the air .
[1]: /storage/temp/113269-capture-decran-111.png
capture-decran-111.png
(152.4 kB)
Comment