Created
September 24, 2018 23:30
-
-
Save Gondlir/b306df903d4ad5dd2ccdc329ccb2fa77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Script1 : MonoBehaviour { | |
public float velocidade; | |
//private Rigidbody2D rigidB; | |
void Start() | |
{ | |
//rigidB = GetComponent<Rigidbody2D> (); | |
} | |
void Update(){ | |
if (Input.GetKeyDown (KeyCode.Space)) { | |
GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, 500)); | |
} | |
} | |
void FixedUpdate() | |
{ | |
float Horizontalpoint = Input.GetAxis ("Horizontal"); | |
float Horizontalpoint2 = Input.GetAxis ("Vertical"); | |
GetComponent<Rigidbody2D> ().velocity = new Vector2 (Horizontalpoint*velocidade, GetComponent<Rigidbody2D> ().velocity.y); | |
GetComponent<Rigidbody2D> ().velocity = new Vector2 (Horizontalpoint2*velocidade, GetComponent<Rigidbody2D> ().velocity.x); | |
//float Verticalpoint = Input.GetAxis ("Vertical"); | |
//Vector2 movimento = new Vector2 (Horizontalpoint, Verticalpoint); | |
//rigidB.AddForce (movimento * velocidade); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment