Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
2
Question by dfego · Feb 25, 2017 at 11:24 PM · standard-assetsfpscontrollerbest-practices

Best practices for using and modifying Standard Assets?

Short version: I want to use the FPSController Standard Asset (or any SA for that matter) but want to extend and modify its functionality. Is there a best practice for this scenario in relation to copying/subclassing/encapsulating/etc.?

Longer version...

I'm currently messing around with a basic FPS. Placed in the FPSController Standard Asset. Now I'm trying to add to and modify the FPSController (player) with my own scripts (having a stamina bar), and I was wondering if there's any best practices around this. Issues I'm having:

  1. If I try to add my own scripts to be referenced by FPSController (e.g. a PlayerStamina script I wrote), it doesn't seem to be able to find it, because it's in its own namespace? Making my own namespace and trying to use that hasn't worked yet.

  2. I could copy FirstPersonController.cs to my own scripts, but the whole prefab has a lot of other baggage with it, so that doesn't seem like the intended way.

  3. I could wrap the FPSController object with another Object, but not sure what that'll get me.

  4. I could try subclassing (in code) the Standard Asset script, and then reference that script in the prefab instead? Would this have issues with namespaces?

To be clear: I'm not looking for help with the specifics (making a stamina bar or state, etc.), just trying to figure out how to best work with and around the Standard Assets, since they're segmented off from my own assets and don't seem to have ready access to my own scripts.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by dfego · Feb 27, 2017 at 03:46 AM

I ended up copying the components I needed into my own Assets and scripts and then paring them down as needed. It helped me get a better understanding of what's there, and now I can freely modify it with whatever is needed!

Thanks again to @Miguelcldn for his suggestion. I will likely organize some of my additions to these components like that!

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

Answer by Miguelcldn · Feb 26, 2017 at 03:59 PM

Hi @dfego, I'm not pretty sure if this helps you out, but I was in the same situation and my solution was to just add my own scripts as components to the FirstPersonController so its components end up like this:

 First Person Controller (Script)
 Player (Script)
 Player Stats (Script)
 [Other components]

This way the First Person Controller do its job: Control the player, while the Player and Player Stats scripts are my own, where I add the extra functionality I need in the GameObject. I keep the Stamina/Health bars and its control in a separate script (Player Stats) to keep Player cleaner.

Comment
Add comment · Show 1 · 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 dfego · Feb 26, 2017 at 06:40 PM 0
Share

@$$anonymous$$iguelcldn Thanks for the response! Question for your setup. FirstPersonController has sprinting (with LeftShift), which I'd like to tie to my sta$$anonymous$$a. Did you tie these together somehow? For my initial test I just check for LeftShift in my Sta$$anonymous$$a code, but that feels like bad design since I already look for and handle the input in the FirstPersonController.

The long-term solution might be to make my own prefab, pulling out the pieces of FirstPersonController that I like!

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

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change position to character in first person view? 0 Answers

standard Assest 1 Answer

How to modify the MouseLook script to use GetComponent and use other custom scripts. 0 Answers

which is the best software to make an fps 0 Answers

standoff 2 like character swipe 0 Answers


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