Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 MikezNesh · Jul 01, 2010 at 11:19 AM · fpsshootingaimingmechanics

Best way for setting up shooting mechanics for an FPS? (iPhone)

What would be the best way to set up shooting mechanics in a FPS? I know how to instantiate a bullet from a spawn point but...

How would you set up the little circle which signifies where you shoot at?

And how would you set the reloading mechanics?

(Please don't tell me to use the FPS game Unity provided because that doesn't work for Unity iPhone).

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Novodantis 1 · Jul 01, 2010 at 01:23 PM

If this is for an iPhone then I recommend editing the question to include it in the title/tag, as it's pretty important.

I'm guessing you will use an on-screen thumb stick for movement and an on-screen button to shoot?

Firstly I would use raycasting for shots, unless you need to see the actual projectile, as physics is costly on the iPhone (I'm sure you know). The crosshair circle (where you aim) should be as simple as a GUI graphic in the center of the screen (unless we're firing something with gravity/bounce behaviour). Reloading can be simple as a value reset with sound effect, or can include an animation if the weapon is visible.

eg:

var ammunition:int = 200; var reload:boolean = false; var pressedReload:boolean var pressedFire:boolean // <- replace with whatever input is Fire

if (pressedFire && ammunition) { // <- play shoot sound here ammunition -= 1; // <- firing / hit testing code here } if (ammunition <= 0) { // <- play empty sound here ammunition = 0; reload = true; } if (pressedReload && reload) { // <- play reloading sound here ammunition = 200; reload = false; }

This is a very simple script, you can of course make many improvements (like a delay so reload is not instantaneous), but you get the idea from it...

Comment
Add comment · Show 7 · Share
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 MikezNesh · Jul 01, 2010 at 01:28 PM 0
Share

Edited title like you said and yes yusing thumb stick and such.

avatar image MikezNesh · Jul 01, 2010 at 01:30 PM 0
Share

How do you make the crosshair circle follow your movement?

avatar image MikezNesh · Jul 01, 2010 at 01:31 PM 0
Share

How can I add it so the cross hair moves if I move my thumb stick? And how do I make the gun shoot aim at the cross hair circle?

avatar image MikezNesh · Jul 01, 2010 at 01:43 PM 0
Share

How should I do the raycast to shoot?

avatar image Novodantis 1 · Jul 01, 2010 at 04:35 PM 0
Share

Normally in an FPS the look control moves the camera, and the crosshair is fixed to the center of that. Unless we're talking more like an on-the-rails shooter, eg. Time Crisis?

Show more comments

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Multiple Cars not working 1 Answer

aiming at center of screen 1 Answer

What is wrong with this shooting script? 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Shooting Script Help 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