Animator set float
I am beginner in developing a game in unity3d. I just found a script for moving a character. So, I'm just confused a little bit in this script. Here's the code that I don't understand.
if (Input.GetAxis ("Vertical") == 0 && Input.GetAxis ("Horizontal") == 0) {
animator.SetFloat ("PlayerState", IDLE);
}
I don't understand the line: animator.SetFloat("PlayerState", IDLE);
What is PlayerState and IDLE? I know it's a parameter. Is IDLE a variable? How does it works? Can you enlighten me guys?
PS: On the source code that I found, you can't actually see any variables.
Added Code
Another code that I don't understand. Assume that the player holds the LShift and W key then the character will run, right? How did the script checks the animator if the character will run? Another thing is, since I have a variable RUN which has a value of 4f, will I remove the line moveSpeed = 4f; or not?
Here is the script:
if (Input.GetKey (KeyCode.LeftShift)) {
if (Input.GetAxis ("Vertical") > 0) {
moveSpeed = 4f;
Quaternion turnAngle = Quaternion.Euler (0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp (character.rotation, turnAngle, Time.deltaTime * rotationSpeed);
animator.SetFloat ("PlayerState", RUN);
}
}
c# unity3d
add a comment |
I am beginner in developing a game in unity3d. I just found a script for moving a character. So, I'm just confused a little bit in this script. Here's the code that I don't understand.
if (Input.GetAxis ("Vertical") == 0 && Input.GetAxis ("Horizontal") == 0) {
animator.SetFloat ("PlayerState", IDLE);
}
I don't understand the line: animator.SetFloat("PlayerState", IDLE);
What is PlayerState and IDLE? I know it's a parameter. Is IDLE a variable? How does it works? Can you enlighten me guys?
PS: On the source code that I found, you can't actually see any variables.
Added Code
Another code that I don't understand. Assume that the player holds the LShift and W key then the character will run, right? How did the script checks the animator if the character will run? Another thing is, since I have a variable RUN which has a value of 4f, will I remove the line moveSpeed = 4f; or not?
Here is the script:
if (Input.GetKey (KeyCode.LeftShift)) {
if (Input.GetAxis ("Vertical") > 0) {
moveSpeed = 4f;
Quaternion turnAngle = Quaternion.Euler (0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp (character.rotation, turnAngle, Time.deltaTime * rotationSpeed);
animator.SetFloat ("PlayerState", RUN);
}
}
c# unity3d
It's probably some variablefloat IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18
add a comment |
I am beginner in developing a game in unity3d. I just found a script for moving a character. So, I'm just confused a little bit in this script. Here's the code that I don't understand.
if (Input.GetAxis ("Vertical") == 0 && Input.GetAxis ("Horizontal") == 0) {
animator.SetFloat ("PlayerState", IDLE);
}
I don't understand the line: animator.SetFloat("PlayerState", IDLE);
What is PlayerState and IDLE? I know it's a parameter. Is IDLE a variable? How does it works? Can you enlighten me guys?
PS: On the source code that I found, you can't actually see any variables.
Added Code
Another code that I don't understand. Assume that the player holds the LShift and W key then the character will run, right? How did the script checks the animator if the character will run? Another thing is, since I have a variable RUN which has a value of 4f, will I remove the line moveSpeed = 4f; or not?
Here is the script:
if (Input.GetKey (KeyCode.LeftShift)) {
if (Input.GetAxis ("Vertical") > 0) {
moveSpeed = 4f;
Quaternion turnAngle = Quaternion.Euler (0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp (character.rotation, turnAngle, Time.deltaTime * rotationSpeed);
animator.SetFloat ("PlayerState", RUN);
}
}
c# unity3d
I am beginner in developing a game in unity3d. I just found a script for moving a character. So, I'm just confused a little bit in this script. Here's the code that I don't understand.
if (Input.GetAxis ("Vertical") == 0 && Input.GetAxis ("Horizontal") == 0) {
animator.SetFloat ("PlayerState", IDLE);
}
I don't understand the line: animator.SetFloat("PlayerState", IDLE);
What is PlayerState and IDLE? I know it's a parameter. Is IDLE a variable? How does it works? Can you enlighten me guys?
PS: On the source code that I found, you can't actually see any variables.
Added Code
Another code that I don't understand. Assume that the player holds the LShift and W key then the character will run, right? How did the script checks the animator if the character will run? Another thing is, since I have a variable RUN which has a value of 4f, will I remove the line moveSpeed = 4f; or not?
Here is the script:
if (Input.GetKey (KeyCode.LeftShift)) {
if (Input.GetAxis ("Vertical") > 0) {
moveSpeed = 4f;
Quaternion turnAngle = Quaternion.Euler (0, centerPoint.eulerAngles.y, 0);
character.rotation = Quaternion.Slerp (character.rotation, turnAngle, Time.deltaTime * rotationSpeed);
animator.SetFloat ("PlayerState", RUN);
}
}
c# unity3d
c# unity3d
edited Nov 14 '18 at 13:17
J.Wujeck
asked Nov 14 '18 at 10:54
J.WujeckJ.Wujeck
358
358
It's probably some variablefloat IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18
add a comment |
It's probably some variablefloat IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18
It's probably some variable
float IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
It's probably some variable
float IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18
add a comment |
1 Answer
1
active
oldest
votes
Documentation is your friend. The method you are talking about is explained in detail here.
Basically animator
variable is a reference to Animator
object, which you created using Unity's Animator. Here is a picture to the menu I am talking about.
"PlayerState" in your example code is an condition you create in Unity's Animator. In the picture I pasted the condition is "horizontalSpeed". Most probably IDLE
is defined somewhere else in the code you pasted, and must be a value which will set the animation to IDLE
state such as float IDLE = 0f
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298537%2fanimator-set-float%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Documentation is your friend. The method you are talking about is explained in detail here.
Basically animator
variable is a reference to Animator
object, which you created using Unity's Animator. Here is a picture to the menu I am talking about.
"PlayerState" in your example code is an condition you create in Unity's Animator. In the picture I pasted the condition is "horizontalSpeed". Most probably IDLE
is defined somewhere else in the code you pasted, and must be a value which will set the animation to IDLE
state such as float IDLE = 0f
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
add a comment |
Documentation is your friend. The method you are talking about is explained in detail here.
Basically animator
variable is a reference to Animator
object, which you created using Unity's Animator. Here is a picture to the menu I am talking about.
"PlayerState" in your example code is an condition you create in Unity's Animator. In the picture I pasted the condition is "horizontalSpeed". Most probably IDLE
is defined somewhere else in the code you pasted, and must be a value which will set the animation to IDLE
state such as float IDLE = 0f
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
add a comment |
Documentation is your friend. The method you are talking about is explained in detail here.
Basically animator
variable is a reference to Animator
object, which you created using Unity's Animator. Here is a picture to the menu I am talking about.
"PlayerState" in your example code is an condition you create in Unity's Animator. In the picture I pasted the condition is "horizontalSpeed". Most probably IDLE
is defined somewhere else in the code you pasted, and must be a value which will set the animation to IDLE
state such as float IDLE = 0f
Documentation is your friend. The method you are talking about is explained in detail here.
Basically animator
variable is a reference to Animator
object, which you created using Unity's Animator. Here is a picture to the menu I am talking about.
"PlayerState" in your example code is an condition you create in Unity's Animator. In the picture I pasted the condition is "horizontalSpeed". Most probably IDLE
is defined somewhere else in the code you pasted, and must be a value which will set the animation to IDLE
state such as float IDLE = 0f
answered Nov 14 '18 at 11:16
Hasan Emrah SüngüHasan Emrah Süngü
1,662319
1,662319
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
add a comment |
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
What if the code is animator.SetFloat ("PlayerState", RUN); Should I create a variable in script like this one; public float RUN = 4f; ?
– J.Wujeck
Nov 14 '18 at 11:43
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
@J.Wujeck yes, that's correct. PlayerState is a parameter in the referenced Animator, and animations will play based on the conditions of the Animator animation transitions. These conditions are based on the parameters.
– JTizzle
Nov 14 '18 at 12:13
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
Hi guys. I just added some code above. Can you explain it to me? Thanks!
– J.Wujeck
Nov 14 '18 at 12:38
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298537%2fanimator-set-float%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's probably some variable
float IDLE = 0f
– Morasiu
Nov 14 '18 at 11:09
1. If you have a new question please open a new one. 2. In this case don't, I'ld rather suggest you take a step back and watch some tutorials on the basics of c# and Unity.
– derHugo
Nov 14 '18 at 18:18