Animator set float












0















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);
}
}









share|improve this question

























  • 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


















0















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);
}
}









share|improve this question

























  • 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
















0












0








0








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);
}
}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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





















  • 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



















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














1 Answer
1






active

oldest

votes


















3














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.enter image description here



"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






share|improve this answer
























  • 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











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
});


}
});














draft saved

draft discarded


















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









3














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.enter image description here



"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






share|improve this answer
























  • 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
















3














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.enter image description here



"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






share|improve this answer
























  • 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














3












3








3







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.enter image description here



"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






share|improve this answer













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.enter image description here



"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







share|improve this answer












share|improve this answer



share|improve this answer










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



















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python