- Home /
Weapon firing and weapon selection mechanism for C# game
Hi i will get straight to the point I'm building a little personal project (i say personal as in its for practice because its actually my first game) and i have done a lot of research for a couple days looking for answers and presets for building a weapon system that fires cannons on a large ship from either the Portside or the Starboard side or even the bow (front of the ship i also have mortars on the main deck). the only thing i can find coming close to what i need is scripts for modern day weaponry and since i don't even understand how to read code all that well if at all, i want to know if anyone out there knows how to either convert the scripts to what i need or help me figure out how to write it myself. any help is greatly appreciated, thank you.
Some tips.
Represent each cannon muzzle as an empty gameobject pointing in the direction the cannonball would fly. Create a simple gameobject with a cannonball mesh (sphere), give it a rigidbody, and make a prefab out of it. When a cannon should fire, instantiate a copy of that prefab and use RigidBody.AddForce to make it fly forward in a nice arc. Use the Unity User $$anonymous$$anual and Scripting API for further information on the required functions and variables. If you also want a muzzle flash, give the muzzle object a meshrenderer or particlesystem with the appropriate graphics. Use a Coroutine in for tformer case to enable the $$anonymous$$eshRenderer for a fraction of a second to simulate the flash. If using a ParticleSystem, use ParticleSystem.Emit to emit a number of particles. The cannonball itself can also be given a TrailRenderer or ParticleSystem for a trail or smoke effect.
i don't understand, i have the dastardly banana weapons pack but i can't even get that to work and i don't know how to read of write code languages. could you please give a basic example of what you mean ore even a link to a tutorial would help me, i just can't wrap my head around this weapon system. thanks
To be honest, you will struggle to get anywhere unless you start learning to code. The Unity $$anonymous$$m have done a great job of making this as easy as possible. http://unity3d.com/learn/tutorials
They key is to realise that like most things, you'll need to start simple and build your knowledge and experience over time. If you don't understand something, work your way backwards to the simplest aspect you do understand and start tackling it from that point forward.
i've just tried googling answers and definitions to find out why my scripts are not working even though i write them exactly how it is down in the demonstrations and tutorials (i do replace their objects with my own so its compatible with my project) and still nothing is working for me i even went to the link u sent me for a couple hours watching their tutorial and nothing is working, my scripts don't bring up the options in the inspector where some scripts will have customisation options to place objects and things. what am i doing wrong? why can't i just build what i need and move to the next part?
As ijidau said, if you don't understand how parts of even all of a script works, then it's pointless to go on. You need to be able to read and understand code, plain and simple. I recommend creating a few sample scripts which have just a few lines of code; one for learning how to clone objects, one for registering input, one to make a Rigidbody move, and so on. If you can get those to work and more importantly, know why, then you can try and combine what you have learned.
Your answer
Follow this Question
Related Questions
Area Effect Damage 2 Answers
Coding a class swapping system 1 Answer
I need help with attaching/detaching weapons to a character 0 Answers
Coding a class swapping system 0 Answers
Shooting Cannons from a boat 1 Answer