Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

»Ï¤á¤ËºîÀ®¤·¤¿¡ÖPlayerController¡×¤Î¥¹¥¯¥ê¥×¥È¤Ë¤ÏÊÑ¿ô¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
¤½¤Î¤¿¤á¸½ºß¡¢Player¤Î°Üư®Å٤ϰìÄêÃͤǤ¹¡£

¤½¤³¤Çº£¸å¤Î¤¿¤á¤Ë¡¢¤Þ¤º¤Ï½¤¾þ»Ò¤Î¤Ä¤¤¤¿ÊÑ¿ô¤òÍÑ°Õ¤·¤Þ¤·¤ç¤¦¡£
¤³¤Á¤é¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤ÇPlayer¤Î°Üư®ÅÙ¤ò²ÄÊѤǤ­¤ë¾õÂ֤ˤ¹¤ë¤³¤È¤¬ÌÜŪ¤Ç¤¹¡£

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private float moveSpeed;      // <= °Üư®ÅÙÍѤÎÊÑ¿ô¤òÄɲÃ

    // Start is called before the first frame update
    void Start()
    {
        moveSpeed = 0.05f;        // <= °Üư®ÅÙÍѤˡ¢ÃͤòÂåÆþ
        Debug.Log(moveSpeed);     // <= ÂåÆþ³ÎǧÍÑ
    }

    // Update is called once per frame
    void Update()
    {    
        // º¸Ìð°õ¤¬²¡¤µ¤ì¤¿»þ
        if(Input.GetKey(KeyCode.LeftArrow))
        {
                // º¸¤Ë¡Ö3¡×Æ°¤«¤¹
                transform.Translate(-moveSpeed, 0, 0);    // <= x ¤ÎÃͤò -0,05f ¤«¤é -moveSpeed¤ËÊѹ¹¤¹¤ë  
        }
        // ±¦Ìð°õ¤¬²¡¤µ¤ì¤¿»þ
        if(Input.GetKey(KeyCode.RightArrow))
        {
                // ±¦¤Ë¡Ö£³¡×Æ°¤«¤¹
                transform.Translate(moveSpeed, 0, 0);     // <= x ¤ÎÃͤò -0,05f ¤«¤é moveSpeed¤ËÊѹ¹¤¹¤ë 
        }
    }
}

¡¡¤³¤ÎÊѹ¹¤Ë¤è¤ê¡¢°ÜÆ°¤ËÍøÍѤ¹¤ë x ¤ÎÃͤò 0.05f ¤È¤¤¤¦¸ÇÄêÃͤ«¤é¡¢ÊÑ¿ô¤Ø¤ÈÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤·¤¿¡£
º£²ó¤Ï¸ÇÄêÃͤÈƱ¤¸ÃͤòmoveSpeed¤ËÂåÆþ¤·¤Æ¤¤¤Þ¤¹¡ÊDebug.Log¤Ç³Îǧ¤·¤Æ¤¤¤Þ¤¹¡Ë¡£
¡¡Æ±¤¸Æ°¤­¤ò¤¹¤ë¤«¡¢³Îǧ¤ò¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¡¡¤³¤ì¤Ë¤è¤ê¡¢Player¤Î°ÜÆ°¤Ë´Ø¤¹¤ë x ¤ÎÃͤϲÄÊѲ½¤¹¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤·¤¿¡£
Î㤨¤Ð¡¢moveSpeed = 0.1f¡¡¤Ë¤Ê¤ì¤Ð¡¢¸½ºß¤Î°Üư®ÅÙ¤Î2Çܤή¤µ¤Ç°ÜÆ°¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu


´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹