• 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 lvlup · Jan 22, 2011 at 06:17 AM · componentvaluehow

adjusting Component values with scripts?

i'm new! to everything unity!

how do i, or what do i type, in my c# script, if i want to edit the value of one of the component variables?

example: Component > Constant Force > Force > X Y Z - "i want to edit Z value/adjustable with script"

so that the Z value can be changed in the game..

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

Answer by uhahaha · Jan 22, 2011 at 01:28 PM

Assign Vector3 to force, for example, 10 to z direction like:

constantForce.force = Vector3(0,0,10);

the keyword forward denotes the z direction, so you can use in the RHS

Vector3.forward * 10;
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 lvlup · Jan 23, 2011 at 07:18 AM 0
Share

where can i find that "constantforce.force", how did u know is that, is it in the API Reference or something?

when i add the "Component" "Force" in the unity engine, i understand it afterall is already a script, was looking for the script so i could control/make my own edits via script not through the Inspector.

so thanks, this is the answer i was looking for =)

avatar image uhahaha · Jan 24, 2011 at 05:22 AM 0
Share

It's in the Script Reference. Search for constantforce then you get all pertinent variables & functions.

avatar image
1
Best Answer

Answer by Jesse Anders · Jan 22, 2011 at 01:37 PM

Is this what you're looking for:

public int myVariableThatCanBeEditedInTheInspector;

?

[Nm; I think I misunderstood the question.]

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 lvlup · Jan 23, 2011 at 07:19 AM 0
Share

that helps alot too! thanks!

now i understand how to create my own "Inspector" fields =)!

so, "public int" is java? or cs? or does it not make a difference,

i have zero experience training with scripts/coding, i'm an artist ^_^

avatar image Jesse Anders · Jan 23, 2011 at 08:49 AM 0
Share

In this context it's in C# (Java isn't supported in Unity).

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

No one has followed this question yet.

Related Questions

How to get a value from an array within another script. 1 Answer

Can I access components scripts? 3 Answers

script communicate with each other 0 Answers

How can i remove two scripts from a GameObject that depend on eachother? 0 Answers

way to get all object with a certain component/script attached 3 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