How to make bullet originate from enemy (walktall)?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

How to make bullet originate from enemy (walktall)?

Post by sheamkennedy »

EDIT: Disregard this, I figured it out!

So far I have a code on-keypress that shoots a bullet originating from my hero using a function like:

Code: Select all

set parent(Bullet, get hero slice (0)) 
Now I want to make my enemies shoot bullets. Since I am using the walktall script all my heroes and NPCs use the "hero sprites" in place of normal walkabout sprites. So how do I parent my enemy bullets to my enemies?

I looked in to "get hero slice," but the dictionary says it only accepts values for heroes in the party, not NPCs outside the party...
Last edited by sheamkennedy on Wed Apr 29, 2015 8:29 pm, edited 1 time in total.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Normally projectiles shouldn't be parented to whatever fires them, but I know you want the bullets to match the movements of whoever is firing...
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

TMC wrote:Normally projectiles shouldn't be parented to whatever fires them, but I know you want the bullets to match the movements of whoever is firing...
Actually what would be the best way to have them originate from an enemy but not be parented to them? (Sorry if this seems like a silly question) I think in many cases I will want the projectiles parented to my enemy, but in a few cases I may not want to do this too (like for fast moving driveby enemies).

Also I did plan on having some complex firing patterns that work by originating a bullet at the enemy who fires it, but parent the bullet to an invisible pacing enemy who actually controls how the bullet moves side to side. I figure this would be the easiest way to create sinusoidal bullet movement without coding a bunch of math which I tend to be poor it in cases like that.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

I would normally make bullets siblings of the enemy and player slices, so they would all share the same parent (probably the map)

To make a bullet originate at an enemy, just set its x and y to be equal to the enemy's x and y when you create the bullet.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

I'm assuming the advantage of using siblings is that since every bullet shares a common parent then altering that parent can alter all the bullets at once?

Thanks for the response. I'll hopefully get around to trying this soon since I've been making good progress on enemy creation.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Well, for myself, the main advantage of keeping enemies and projectiles as siblings in my own scripts is that I can easily loop through them and run scripts that update them each tick. That might not be something you want to do for your game, so you might prefer to stick with the parenting methods you already have.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Bob the Hamster wrote:Well, for myself, the main advantage of keeping enemies and projectiles as siblings in my own scripts is that I can easily loop through them and run scripts that update them each tick. That might not be something you want to do for your game, so you might prefer to stick with the parenting methods you already have.
Oh I see how that would be useful for animating purposes. I'll keep that in mind.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Post Reply