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 8Eye · Oct 24, 2014 at 04:33 PM · template

Whers should i use this code template?

I was looking through the auto code templates and i found this so i tries using it to crouch my character.

     public PC_Control (bool isCrouching)
     {
         this.isCrouching = isCrouching;
     }
         bool Crouch(){
 
         return isCrouching;
     
     }

Ive been trying to get it working but im not sure what im doing. I wanted to learn a few new things today and this is one of them. I tried looking on the internet but the examples are a little bit alien to me.

My initial goal is to make my character crouch with the s key and then stand up again when i let go of the s key.

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
1
Best Answer

Answer by Anxo · Oct 24, 2014 at 04:44 PM

Hi,

I think you may be better off starting on this page. http://unity3d.com/learn/tutorials/modules/beginner/scripting

I recommend doing ALL of the beginner tutorials before actually attempting to create something as you may just end in frustration or give up on your project. It only takes a little while and will give you a good understanding of most of the things you need.

As to your question, First, your code does not work. You have a public PC_Control, so you would have to have a class called PC_Control but you are returning a bool "return isCrouching that you are passing into the method.

If you have an animation of your character or a bool you want to set for your character to crouch you could use something along the lines of.

 if(Input.GetKeyDown(KeyCode.S)){
   Debug.Log("Crouch Code here");
 }
 if(Input.GetKeyUp(KeyCode.S)){
   Debug.Log("Stand Up Here");
 }


But again, I would recommend getting your understanding of the fundamentals up to speed first so you give yourself the power to do the things you want to do.

Comment
Add comment · Show 2 · 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 8Eye · Oct 24, 2014 at 04:47 PM 0
Share

Ok thanks for replying.

avatar image 8Eye · Oct 24, 2014 at 04:48 PM 0
Share

Awesome link.

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

29 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

Related Questions

WebPlayer HTML Object Resize (with Aspect Ratio) 0 Answers

How can i change the default new scene? 1 Answer

Change the default script template? 5 Answers

generic / templatized components / monobehaviors ? 0 Answers

How to resolve Unity HDRP will not work until error is fixed problem 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