Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvl83/219be2d2330566037e0682f5d3f18a36 to your computer and use it in GitHub Desktop.
Save tvl83/219be2d2330566037e0682f5d3f18a36 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class danger1rotation : MonoBehaviour {
{
public Transform speed = 10.0f; //this is for normal speed
public Transform Jumpspeed = 20.9f; //this is for jump speed
public Transform slowspeed = 05.00f; //this is for the slow speed
public Transform fastspeed = 40.00f; // this is for the fast speed
public Transform animator1;
public Transform animator2;
public Transform animator3;
public Transform animator4;
void update()
{
if(input.GetKey(KeyCode.W))
{
if(input.GetKey(KeyCode.UpArrow) // Spelling mistake
{
animator1 = GetComponent<Animator>();
//moving forward
transform.position = Vector3.forward * speed * Time.deltaTime;
Debug.Log("player is moving forward");
Debug.Log("moving with the speed of 10.0f");
}else{
if(Input.GetKey(KeyCode.Space))
{
transform.position = Vector3.forward * fastspeed * Time.deltaTime;
Debug.Log("character is moving dem fast");
}else{
if(Input.GetKey(KeyCode.V))
{
transform.position = Vector3.forward * slowspeed * Time.deltaTime;
Debug.Log("character is moving dem slow");
}
}
}
}
//this is a block of code
if(input.GetKey(KeyCode.S))
{
if(input.GetKey(KeyCode.DownArrow) // Spelling mistake
{
animator2 = GetComponent<Animator>();
//code to be executed
transform.position = Vector3.backward * speed * Time.deltaTime;
Debug.Log("Player is moving backward");
Debug.Log("moving with the speed of 10.0f");
}
}
if(input.GetKey(KeyCode.A))
{
if(input.GetKey(KeyCode.LeftArrow) // Spelling mistake
{
animator3 = GetComponent<Animator>();
//This make the character turn Vertical
transform.Translate(Vector3.left * Input.GetAxis("Vertical") * speed * Time.deltaTime);
Debug.Log("Player is moving backward");
Debug.Log("moving with the speed of 10.0f");
}
}
if(input.GetKey(KeyCode.A))
{
if(input.GetKey(KeyCode.LeftArrow) // Spelling mistake
{
animator4 = GetComponent<Animator>();
//This make the character turn Vertical
transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * speed * Time.deltaTime);
Debug.Log("Player is moving backward");
Debug.Log("moving with the speed of 10.0f");
}
}
if(input.GetButtonDown("Jump")) // spelling mistake
{
Jump();
}
}
void Jump()
{
if(Input.GetButtonDown("Jump"))
{
rb.GetComponent<Rigidbody>();
transform.position = Vector3.up * Jumpspeed * Time.deltaTime;
Debug.Log("Jump");
}else{
transform.position = Vector3.down * Jumpspeed * Time.deltaTime;
Debug.Log("character is going down");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment