- Home /
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..
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;
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 =)
It's in the Script Reference. Search for constantforce then you get all pertinent variables & functions.
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.]
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 ^_^
In this context it's in C# (Java isn't supported in Unity).
Your answer
![](https://koobas.hobune.stream/wayback/20220613100542im_/https://answers.unity.com/themes/thub/images/avi.jpg)