Shoot

Description

The Shoot behavior is an action behavior. When executed it will make your selected object shoot a projectile. This behavior contains predefined properties to make the creation of certain games easier. It's perfect for shooter games.

The Shoot behavior offers a lot of properties to customize the feel of your game. Try modifying the properties so your game doesn't feel like a generic shooter. 

This behavior will Trigger an event once immediately when executed.

 

Properties

Triggers Immediately

Object A

This is the object that will be doing the shooting. By default the current object is selected, but you can tap the graphic to change it to any other object in your scene. Also note, that when selecting an object the blue target represents where the bullet will shoot from. You can move the blue target any where, and it will update the emitter location.

Sound

You can select a sound effect to play when you shoot.

Bullet Graphic

This is the graphic that represents the projectile you're shooting. Note that the size of the graphic is how big your bullet (and collision shape) will be. 

Emitter Position

This is the position where the projectile/bullet will shoot from. By default the bullet will shoot from the centre of the object. You can also use the Object B selector to visually change the emitter position by moving the blue target.

Initial Speed

This is the speed that your bullet will shot at. Note, that if the "Physics" toggle is on, your bullet will slowdown due to other forces (gravity, air resistance etc.) The default value is 30 m/s.

Distance

This is how far the bullet can reach before it no longer exists. The default value is 32 meters.

Shoot Angle

This is the angle that the bullet is being shot from the object. ie. You can shoot from the front of the object instead of the top. The default value is 90 degrees.

Bullet Rotation

This value sets the rotation of the graphic that represents your projectile. Change this value if your bullet is facing the wrong direction. The default value is 0 degrees.

Spray Range

This is the spread of the bullets emitting from the object. If you have multiple bullets you can increase this angle to have them spread further apart. This is useful for creating a machine gun type weapon. The default value is 30 degrees.

Spray Variance

This value adds some randomness to the spread of the bullets (Spray Range). The higher the number, the more random your bullets appear to be. This is great for simulating recoil for a machine gun type weapon. The default value is 0%.

# Bullets

This is the amount of bullets that will emit when you press the shoot button. The default value is 1.

Delay

This is how long the gun will wait before emitting another bullet. This is useful if you want to slowdown the stream of projectiles and create a space between them. The default value is 0.5 seconds.

Physics

This toggle controls whether or not the bullets will conform to the physics engine. If this is on, gravity and other external forces will impact the speed and direction of your bullet. By default this toggle is off.

Destroy on Impact

Toggle that controls whether or not the bullets die when they collide with other objects. If this toggle is off, and physics are off your bullets will bounce around the scene. By default this toggle is on.

# Alive Bullets

This value controls how many bullets can be on screen at one time. Once you have shot this amount of bullets and they are still alive in the scene, you will not be able to shoot any more.

Play Animations

When this toggle is on, your object will play an animation when the shoot button is pressed. You must select an animation from the Custom Animations panel.

Custom Animations

On the left panel you can select an animation cycle to play when you press the shoot button. 

Animation Priority

On the left Custom Animations panel, you can prioritize your shoot animations so it does not conflict with another playing animation. The animation system will play a cycle with a higher priority. So if another animation behavior is interrupting your shoot animation, try increasing the priority.

 

Outputs

Object ID

This outputs the Object ID.

 

Examples

If you want to make a shooter game  you can simply add this behavior to your player object, and it will automatically create a button on your Global UI layer, and make your character able to shoot. By modifying the properties you can create a wide range of weapons from pistols, machine guns, rocket launchers, or other projectile based weapons.

Download Example Project

 

Related

Joystick Controlled

Hit by Bullet

Ignore Bullet

Ignore Object's Bullets

Shoot with Button 

 

ShootReference.gif

0 Comments

Article is closed for comments.