• 締切済み

unity fの意味

unityでこういうスクリプトを書きました。 ~~~~~~ using UnityEngine; using System.Collections; public class IfStatements : MonoBehaviour { float coffeeTemperature = 85.0f; float hotLimitTemperature = 70.0f; float coldLimitTemperature = 40.0f; void Update () { if(Input.GetKeyDown(KeyCode.Space)) TemperatureTest(); coffeeTemperature -= Time.deltaTime * 5f; } void TemperatureTest () { // If the coffee's temperature is greater than the hottest drinking temperature... if(coffeeTemperature > hotLimitTemperature) { // ... do this. print("Coffee is too hot."); } // If it isn't, but the coffee temperature is less than the coldest drinking temperature... else if(coffeeTemperature < coldLimitTemperature) { // ... do this. print("Coffee is too cold."); } // If it is neither of those then... else { // ... do this. print("Coffee is just right."); } } } ~~~~~~~~~ ですが、Consoleには冷たいコーヒーしか出て来ません。 float coffeeTemperature = 85.0f; float hotLimitTemperature = 70.0f; float coldLimitTemperature = 40.0f; これってどういう意味なのでしょうか? 85.0f;って? 回答お願いします。

noname#222355
noname#222355

みんなの回答

回答No.1

普通に85.0と書くとdouble型の定数になります。代入先がfloatとわかっている場合は、85.0fとしてfloat型に型をあわせているということです。

関連するQ&A

  • Unityの質問です。

    ボタンを押すと、キャラクターの真後ろにオブジェクトが出現するようにしたいのですが、 using UnityEngine; using System.Collections; [ExecuteInEditMode()] public class GUIController : MonoBehaviour { public CharacterController characterController; public GameObject character; public GameObject domino; private Vector3 objPosition; // Use this for initialization void Start () { objPosition = new Vector3 (0, 0, 0); } void OnGUI(){ if(GUI.Button(new Rect(600, Screen.height - 160, 120, 120), "おす")){ Debug.Log("ぼたん"); float x = characterController.transform.localPosition.x; float y = characterController.transform.localPosition.y + 0.5f; float z = characterController.transform.localPosition.z - 0.64f; objPosition.Set(x, y, z); Debug.Log (x+","+y+","+z); GameObject domino_prefab = (GameObject)Instantiate(domino,objPosition, characterController.transform.rotation); } } } こうしてみたのですが、うまくキャラクターの真後ろにオブジェクトが出てきてくれません。 どなたか助けてください!

  • Unity について

    Unityでゲームを作っているのですがどうしてもできない部分があり困っています それは 転がる玉にあわせてカメラが動かないのです 転がる玉を作るとカメラが追跡しなく 玉を追ってカメラが追跡するようにすると球が転がりません 理想は転がる玉を一定の距離を保ったまま追跡することなのですが ぜんぜんうまくいかないのです --玉は転がるがカメラが追跡しない方 using UnityEngine; using System.Collections; public class PlayerBehaviour : MonoBehaviour { private void OnCollisionEnter(Collision collision) { Debug.Log("kabe hito"); } public float jumpForce = 10; public float Up = 10; public float Down = 10; public float Right = 10;     public float Left = 10; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetKeyDown(KeyCode.Space)) {      rigidbody.AddForce(0,jumpForce,0); Debug.Log("jump! force=" + jumpForce ); } if(Input.GetKey(KeyCode.UpArrow)) { rigidbody.AddForce(0,0,-Up); Debug.Log("UP force=" + Up ); } if(Input.GetKey(KeyCode.DownArrow)) {      rigidbody.AddForce(0,0,Down); Debug.Log("Down force=" + Down ); } if(Input.GetKey(KeyCode.RightArrow)) { rigidbody.AddForce(-Right,0,0); Debug.Log("Right force=" + Right ); } if(Input.GetKey(KeyCode.LeftArrow)) { rigidbody.AddForce(Left,0,0); Debug.Log("Left force=" + Left ); } } } ------カメラが追跡するが玉は移動するが転がらない方 玉にComponent→Character→Platform Input Controllerを選択 そして玉にJavascriptのThirdPersonCamera 1を入れる ThirdPersonCamera 1の中身は http://forum.unity3d.com/threads/70148-Rotation-around-character-by-pressing-RIGHT-MOUSE-BUTTON のThirdPersonControllerの部分をCharacterControllerに変えたやつ 長くなってしまいましたがほんとに困ってます 助けてください

  • unity スクリプト 意味

    // Patrol.cs using UnityEngine; using System.Collections; public class Patrol : MonoBehaviour { public Transform[] points; private int destPoint = 0; private NavMeshAgent agent; void Start () { agent = GetComponent<NavMeshAgent>(); // Disabling auto-braking allows for continuous movement // between points (ie, the agent doesn't slow down as it // approaches a destination point). agent.autoBraking = false; GotoNextPoint(); } void GotoNextPoint() { // Returns if no points have been set up if (points.Length == 0) return; // Set the agent to go to the currently selected destination. agent.destination = points[destPoint].position; // Choose the next point in the array as the destination, // cycling to the start if necessary. destPoint = (destPoint + 1) % points.Length; } void Update () { // Choose the next destination point when the agent gets // close to the current one. if (agent.remainingDistance < 0.5f) GotoNextPoint(); } } ~~~~~~~~~~~~~~~~~~~~~~~~~~ // Choose the next point in the array as the destination, // cycling to the start if necessary. destPoint = (destPoint + 1) % points.Length; の意味がよく分かりません。説明して貰えませんか? このチュートリアル(http://docs.unity3d.com/jp/current/Manual/nav-AgentPatrol.html)です。

  • 英文の意味を教えて下さい。

    アメリカのネットショップで小物を購入予定です。値引きをお願いしていたのですが返事がきました。すみませんが意味を教えて下さい。お願いします。 sorry we can only do 10% off right now. We had said 15% off if you buy over 10 AAA but for this I can do 12% that’s already much higher than what we offer, our AAA are made of leather and we really can’t discount them too much, you can use code BBB , and the minimum order is NNN and it expires this week. Please let me know if you need anything else, thanks.

  • unityでのC++エラーの原因がわかりません!!

    最近unity2dで横スクロールアクションを勉強していて 今移動するなどのアニメーションを動かそうとしています しかし待機状態から移動するときのアニメーションに移行するスクリプトがうまくいきません 誰か教えてください error CS0411: The type arguments for method `UnityEngine.Component.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitlyというエラーが出ます プログラムはこんな感じです using UnityEngine; using System.Collections; [RequireComponent(typeof(Rigidbody2D))] [RequireComponent(typeof(BoxCollider2D))] public class UnityChanController : MonoBehaviour { public Rigidbody2D cRigidbody2D { get { if(!_cRigidbody2D) _cRigidbody2D = rigidbody2D; return _cRigidbody2D; } } Rigidbody2D _cRigidbody2D; public Transform cTransform { get { if(!_cTransform) _cTransform = transform; return _cTransform; } } Transform _cTransform; public Animator cAnimator { get { if(!_cAnimator) _cAnimator = GetComponent(); return _cAnimator; } } Animator _cAnimator; public float moveSpeed = 5; public float jumpForce = 1000; float InputHorValue; bool isGrounded; bool canJump; void Update() { MecCheck(); InputCheck(); } void InputCheck() { InputHorValue = Input.GetAxisRaw("Horizontal"); if(isGrounded && Input.GetButtonDown("Jump")) canJump = true; } void MecCheck() { bool isRunning = InputHorValue != 0; cAnimator.SetBool("isRunning",isRunning); } void FixedUpdate() { Move(); Jump(); } void Move() { if((cTransform.localScale.x > 0 && InputHorValue < 0) || (cTransform.localScale.x < 0 && InputHorValue > 0)) { Vector2 temp = cTransform.localScale; temp.x *= -1; cTransform.localScale = temp; } cRigidbody2D.velocity = new Vector2(moveSpeed * InputHorValue, cRigidbody2D.velocity.y); } void Jump() { if(canJump) { canJump = false; isGrounded = false; cRigidbody2D.AddForce(Vector2.up * jumpForce); } } void OnCollisionEnter2D(Collision2D col) { if(col.gameObject.tag == "Ground") isGrounded = true; } }

  • 気温が95度??

    こんばんは、 以下の文章を訳していただけないでしょうか。 Well not too much going on here (other than hot) the temperature is around 95 degrees:( よろしくお願い致します。

  • 意味がわかりません

    この部分の意味がわからなくて困っています。わかる方いましたら解説をお願いします。m(_ _)m public void paint(Graphics g){ int w,h; w = (int)getSize().width; h = (int)getSize().height; if(f==0){ bufferGraphics.drawImage(image,0,0,this); bufferGraphics.setColor(Color.white); for(int i=0;i<h;i+=2){ bufferGraphics.drawLine(0,i,w,i); } g.drawImage(buffer,0,0,null); f = 1; } else if(f==1) { bufferGraphics.drawImage(image,0,0,this); bufferGraphics.setColor(Color.white); for(int i=1;i<h;i+=2){ bufferGraphics.drawLine(0,i,w,i); } g.drawImage(buffer,0,0,null); f = 0; } }

    • ベストアンサー
    • Java
  • 簡易電卓にて

    「簡易電卓」のプログラムです。52行目にて「浮動小数点の不正な使用」とエラーが出てしまいます。何が間違っているのでしょうか? void kahou(void); void gennpou(void); void zyouhou(void); void zyohou(void); void zyouyo(void); #include <stdio.h> float q,w,r; int main(void) { int a,e; printf("2項の四則演算をさせるプログラムを実行します。\n"); printf("ちなみに変数は実数処理です。"); printf("第1項を入力してください。\n"); scanf("%f",&q); printf("次に第2項を入力してください。\n"); scanf("%f",&w); printf("最後に演算子を括弧から選択してください。(1)加法(2)減法(3)乗法(4)除法(5)剰余"); scanf("%d",&e); if (e==1) kahou(); else if (e==2) gennpou(); else if (e==3) zyouhou(); else if (e==4) zyohou(); else if (e==5) zyouyo(); else main(); printf("計算結果 %f",r); return 0; } void kahou(void) { r=q+w; } void gennpou(void) { r=q-w; } void zyouhou(void) { r=q*w; } void zyohou(void) { r=q/w; } void zyouyo(void) { r=q%w;    →ここが52行目 } よろしくお願いいたします。

  • 共有体でfloat型の数値を2進数へ変換

    実行結果が思ったとおりの値を算出しません。 なぜでしょうか? 回答のほどよろしくお願いいたします。 (例) 小数入力 >5.0 0000 0000 0000 0000 0100 0000 1010 0000 小数入力 >-5.0 0000 0000 0000 0000 1100 0000 1010 0000 (下記ソース) #include<stdio.h> void float_binary(float a); void main (void) { float fl; printf("小数入力 >"); scanf("%f",&fl); float_binary(fl); } void float_binary(float a) { struct float_data{ short int high_byte; short int low_byte; }; union data{ float num; struct float_data bit; }DATA; int i; DATA.num = a; for(i = 0; i<16; i++){ if(i != 0 && i % 4 == 0){ printf(" "); } if(DATA.bit.high_byte < 0){ printf("1"); } else{ printf("0"); } DATA.bit.high_byte = DATA.bit.high_byte << 1; } for(i = 0; i<16; i++){ if(i % 4 == 0){ printf(" "); } if(DATA.bit.low_byte < 0){ printf("1"); } else{ printf("0"); } DATA.bit.low_byte = DATA.bit.low_byte << 1; } }

  • pictureboxの画像を削除するには?

    Visual C# 2008を使用しています。 ボタンを押すとpictureboxに画像が表示されるプログラムを作成しました。 今度は、その表示された画像をクリックし、別のボタンを押すことでその画像が削除できるようにしたいと思っているのですが、うまくプログラムできません。 誰か教えていただけないでしょうか? ソースコードは以下のようになっています。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace algorithm { public partial class Form1 : Form { int space = 10; public Form1() { InitializeComponent(); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { } private void kihonsyori_Click(object sender, EventArgs e) { if (this.pictureBox1.Image == null) { Bitmap img = new Bitmap(@"C:\Documents and Settings\admin\My Documents\Visual Studio 2008\Projects\algorithm\algorithm\picture\基本処理箱.png"); Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(img, 0, space, 0.4F * img.Width, 0.3F * img.Height); space += 50; img.Dispose(); g.Dispose(); } else { this.pictureBox1.Image.Dispose(); this.pictureBox1.Image = null; } } private void groupBox1_Enter(object sender, EventArgs e) { } private void pictureBox1_Click(object sender, EventArgs e) { } private void hanpuku_Click(object sender, EventArgs e) { if (this.pictureBox1.Image == null) { Bitmap img = new Bitmap(@"C:\Documents and Settings\admin\My Documents\Visual Studio 2008\Projects\algorithm\algorithm\picture\反復箱.png"); Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(img, 0, space, 0.4F * img.Width, 0.3F * img.Height); space += 80; img.Dispose(); g.Dispose(); } else { this.pictureBox1.Image.Dispose(); this.pictureBox1.Image = null; } } private void sentaku_Click(object sender, EventArgs e) { if (this.pictureBox1.Image == null) { Bitmap img = new Bitmap(@"C:\Documents and Settings\admin\My Documents\Visual Studio 2008\Projects\algorithm\algorithm\picture\選択箱.png"); Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(img, 0, space, 0.4F * img.Width, 0.3F * img.Height); space += 80; img.Dispose(); g.Dispose(); } else { this.pictureBox1.Image.Dispose(); this.pictureBox1.Image = null; } } private void sakujyo_Click(object sender, EventArgs e) { pictureBox1.Image = null; space = 0; } } }

専門家に質問してみよう