Skip to main content

AWSD controller with c#

 

  1.  
  2.  using UnityEngine;
  3.  using System.Collections;
  4.  using System.Collections.Generic;
  5.  
  6.  [RequireComponent (typeof(Rigidbody))]
  7.  public class PlayerController : MonoBehaviour {
  8.  
  9.      public float movementSpeed = 5.0f;
  10.  
  11.      void Start () {
  12.          
  13.      }
  14.      
  15.      void Update () {
  16.  
  17.         Rigidbody rigidbody = GetComponent<Rigidbody>();
  18.  
  19.          if(Input.GetKey(KeyCode.W)) {
  20.              transform.position += Vector3.forward * Time.deltaTime * movementSpeed;
  21.          }
  22.          else if(Input.GetKey(KeyCode.S)) {
  23.              rigidbody.position += Vector3.back * Time.deltaTime * movementSpeed;
  24.          }
  25.          else if(Input.GetKey(KeyCode.A)) {
  26.              rigidbody.position += Vector3.left * Time.deltaTime * movementSpeed;
  27.          }
  28.          else if(Input.GetKey(KeyCode.D)) {
  29.              rigidbody.position += Vector3.right * Time.deltaTime * movementSpeed;
  30.          }
  31.      }
  32.  }
  33.  

Comments

Popular posts from this blog

Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This tutorial gives a complete understanding of Java. This reference will take you through simple and practical approaches while learning Java Programming language.

  Java Tutorial Java - Home Java - Overview Java - Environment Setup Java - Basic Syntax Java - Object & Classes Java - Constructors Java - Basic Datatypes Java - Variable Types Java - Modifier Types Java - Basic Operators Java - Loop Control Java - Decision Making Java - Numbers Java - Characters Java - Strings Java - Arrays Java - Date & Time Java - Regular Expressions Java - Methods Java - Files and I/O Java - Exceptions Java - Inner classes Java Object Oriented Java - Inheritance Java - Overriding Java - Polymorphism Java - Abstraction Java - Encapsulation Java - Interfaces Java - Packages Java Advanced Java - Data Structures Java - Collections Java - Generics Java - Serialization Java - Networking Java - Sending Email Java - Multithreading Java - Applet Basics Java - Documentation Java Useful Resources Java - Questions and Answers Java - Quick Guide Java - Useful Resources Java - Discussion Java - Examples Selected Reading UPSC IAS Exams Notes Developer's Best Practice

Computing language for chapter 3 : The trigonometric function