Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

wasd code for unity


using UnityEngine;


public class walk : MonoBehaviour
{
    public Rigidbody rb;
    public float ff = 1000f;

    void Start()
    {

        Debug.Log("hello world");
        
    }
    void Update()
    {
        if (Input.GetKey("w"))
        {
            rb.AddForce(0, 0, ff * Time.deltaTime);
        }

        if (Input.GetKey("s"))
        {
            rb.AddForce(0, 0, -ff * Time.deltaTime);
        }


        if (Input.GetKey("d"))
        {
            rb.AddForce(1000 * Time.deltaTime , 0, 0);
        }

        if (Input.GetKey("a"))
        {
            rb.AddForce(-1000 * Time.deltaTime, 0, 0);
        }

    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# pi 
Csharp :: convert number of days into months c# 
Csharp :: difference between awake and start unity 
Csharp :: unity making homing missile 
Csharp :: c# example code 
Csharp :: Map Range Clamped unity 
Csharp :: Plugging a Third-Party IoC Container (e.g. AutoFac) into .NET Core 6 
Csharp :: C# actions 
Csharp :: linked list revrse 
Csharp :: string substring c# before 
Csharp :: how to trim path in C# 
Csharp :: in c sharp how do you work the wait function 
Csharp :: linq find object from id 
Csharp :: c# recursion formula for the factorial 
Csharp :: reverse linked list 
Csharp :: list sort c# 
Csharp :: c# datetime remove days 
Csharp :: c# get all letters 
Csharp :: c# method returns multiple values 
Csharp :: c sharp 
Csharp :: Disable Debug.log Unity 
Csharp :: preprocessors in c# 
Csharp :: c# float 
Csharp :: check if two date ranges overlap c# 
Csharp :: unity auto scroll 
Csharp :: how to do that a objetct moves in c# 
Csharp :: give an alias in model .net 
Csharp :: speech 
Csharp :: unity unhide object 
Csharp :: c# split multiple options 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =