I know that this is a simple line of code, but I just cant remember what it is, I need my gameobject to spawn infront of a different one, but it is just spawning in the player, and it messes things up, here is the code I am currently using and need updated:
void Update()
{
transform.Translate(Vector3.down * speed * Time.deltaTime);
}
Read post number 18 in this thread. what is transform.forward?
It sounds like you just want to set the bullet’s position to be relative to the player:
bullet.transform.position = player.transform.position + player.transform.forward;
1 Like
somewhat, I need the bullet to go in the direction the player is facing, and I also need the bullet to rotate to the player
although that did help me a lot, thanks!
You can actually just set the transform.forward
of the bullet equal to the transform.forward
of the player.
1 Like
but how would I do that?
Referencing GameObjects, Scripts, variables, fields, methods (anything non-static) in other script instances or GameObjects: