Have the bullets of an object stay with the object

How do I make an object shoot but also have the bullets stay with the object?

Also, does anyone know how I could make an enemy follow the player so that the enemy would get closer and closer to the player? [import]uid: 54001 topic_id: 11951 reply_id: 311951[/import]

What exactly do you mean “shoot but also have the bullets stay with the object” ? It’s not clear. You want them to shoot but only a really short distance? Or what?

Peach [import]uid: 52491 topic_id: 11951 reply_id: 43614[/import]

Hi, thanks for replying. I just wanted to know how I should make an object shoot but of course the bullets must stay with the object when it’s moving. How should I do all that exactly?

Take for example a floating gun that is shooting. The bullets fly from the gun barrel and even when the gun is floating the bullets still come from the barrel and not from anywhere else. Hope that makes it more clear for you. [import]uid: 54001 topic_id: 11951 reply_id: 43662[/import]

Oh, you mean you want to spawn them from where the object/gun is and not that you actually want them to stay with gun.

As in, you fire from anywhere and they come out of the gun and go off as a bullet does; NOT that you want to shoot them then have them stay with the gun.

If so, when spawning them, set their position like this;

[lua]bullet.x = gun.x
bullet.y = gun.y[/lua]

Peach [import]uid: 52491 topic_id: 11951 reply_id: 43768[/import]