How do I change the angle of a bullet, but that bullet may be a different object every time?

0 favourites
  • 6 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • So basically, I'm making a twin stick shooter where the weapon randomly changes from among a list of prechosen weapons. I'm storing those weapons in an array as strings and referencing the array index to create the object. The only issue is I'm not sure how I should go about changing the angle of the bullet. How would I reference an object if the object that's needed to be referenced is constantly changing?

  • Use 'bullet on created' to set the angle. If all bullets are going to do the same thing and the problem here is referencing them then you can put all bullet objects into a bullet family and say 'bullet(family) on created' set angle to value, of course this option is only if all bullets do the same thing where the only issue was that you couldn't pick the bullet, otherwise use the bullet object itself to set the desired gameplay for each.

  • I'm still confused on this. I found this option for specific objects like 'Fire on created' but idk how to do just a general 'bullet on created'

  • I *kinda* figured it out. I just have a group called Weapons outside of my canShoot boolean that has a separate event for each weapon to change angle on create to a global variable weaponAngle. Then the set angle in my canShoot boolean is replaced with set value of weaponAngle to the angle it needs to be.

  • You'll need to pay for Construct 3 to access what I was referring to,'Families'. you can put all your bullet objects in a family and call it one time for all. It's so you don't need to do repeat events for many objects. More info in the manual!

    From your last response I see that you want to keep an angle for shooting until you change weapons so yeah a global variable is a good idea, as it is the equipped weapon rather than the bullet. You can also have the equipped weapon as the variable so if weapon ='weaponA' and shoot key is pressed then spawn bullets at a certain angle.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes, families is the key since you have multiple objects. Otherwise you'll have to cleverly and with elbow grease put in some clever events. And you'll eventually run out of free events that Construct 3 allows you to have before you have to upgrade.

    One other approach I use but will also be event heavy is one sprite, multiple animations, and frames within each animation. You'll still need events to check which ammo type or weapon type is used in order to do your work. Shotgun spray for example would act differently than a laser beam, etc..., well in theory.

    I made a weapon one time that had a random bullet type coming out of it from an RPG, to MP5, to Shotgun to grenade (frag, cyro, acid, gas), etc..., it was a lot of fun but a lot of planning to execute.

    I make a lot of sci-fi game environments and use weather patterns to affect projectile performance but don't get me started... I am a Business Intelligence / Data Science professor by day so thinking up all kinds of data, variables, etc.., is my zone.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)