- Home /
Question about making Bullets "not homing"
Hey there!
This is my problem: I have a character and an enemy. The enemy is supposed to aim at the character and shoot a bullet in his direction.
So the direction i get from target.position - transform.position. So far so good. The actual moving is done with transform.Translate.
Now whenever I try to dodge the bullets they curve since they are homing! I just want the bullet to use the initial direction when firing and keeping that.
I feel like this should be an easy fix but I couldnt find anything useful, sorry Im new :(
Answer by highpockets · Nov 28, 2020 at 04:27 PM
You are almost certainly using subtracting the bullet position from the target on every step of the translation. All you should be doing is getting the initial direction and saving that to reuse every frame. You didn’t supply any code so I don’t know your exact scenario, but this should help you a bit:
//your bullet movement likely does something like this
void Update()
{
transform.Translate(( target.position - transform.position).normalized * Time.deltaTime);
}
//It should be doing something like this
Vector3 dir;
void Start()
{
dir = (target.position - transform.position).normalized;
}
void Update()
{
transform.Translate(dir * Time.deltaTime);
}