How would I make a Gun that can suck up debris (like trash) and grenades?

BoneHeadSpark

New member
Is this the right place to ask this question? Or should I move it to the general discussions?

I was playing Blinx The Time Sweeper on my Xbox One, and I wanted to emulate the main weapon and mechanics related to the weapon. The weapon in question is a gun that sucks up trash and shoots it out at enemies. Since my game is all about counter playing attacks with your brain as well as your brawn, I feel like a gun like this would be a neat little thing to encourage more brainy plays against my enemies.

Essentially, the gun would have to do this:

1.) Identify which debris is collectible to suck up.

2.) Suck up the debris to shoot out later

3.) Fire out the exact piece of debris (not just eat the trash and turn it into ammo, but use the trash AS the ammo.) and damage enemies on contact.

For the last one, maybe the trash could have a hitbox that knows to only do damage when the trash collides with an enemy while it's moving at a certain speed? Maybe the damage could scale with the speed, too.

again, I'm sorry if this isn't the right place to ask this question. Most of the question here seems to be about technical support but I didn't see one for coding new weapons.
 

Justin

Administrator
Staff member
This board is great :)

In this case I think that your best bet is to create a new IUsableItem. The functionality is different enough from all of the existing item types that you'll have the best luck just creating a new item from scratch. The flashlight is a good reference to use as it is a pretty basic IUsableItem.
 

BoneHeadSpark

New member
This board is great :)

In this case I think that your best bet is to create a new IUsableItem. The functionality is different enough from all of the existing item types that you'll have the best luck just creating a new item from scratch. The flashlight is a good reference to use as it is a pretty basic IUsableItem.

Sorry for the late reply. I don't get notified like I should for some reason.

Is there a tutorial on creating new IusableItems? I can't seem to find one.
 

Andrew

Moderator
Staff member
There isn't a tutorial in the docs, but you can have a look at Flashlight.cs as a simple example of a custom UsableItem. Some basic starting points:

- When the item is used, use some kind of collision check in front of the player to find debris - destroy them and add to a "Debris" attribute attached to the item
- Use this attribute to fire debris projectiles
- You may even want to use ShootableWeapon as a base for this item, so that it can be a projectile-firing weapon with just the added functionality of gathering the debris (so you'd subclass ShootableWeapon instead of UsableItem)
 
Top