• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Mr Brightside · Nov 12, 2015 at 04:35 PM · shipweapon systemweaponchangingcannoncannonball

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.

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cherno · Nov 12, 2015 at 05:05 PM 0
Share

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.

Show more comments
avatar image ijidau · Nov 13, 2015 at 01:25 AM 1
Share

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.

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

More efficient way to do weapon switching? 1 Answer

Listen to changes on attached by serializefield script? 1 Answer

trouble with cannons 0 Answers

Area Effect Damage 2 Answers

Coding a class swapping system 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges