Skip to content

Instantly share code, notes, and snippets.

@Gondlir
Created September 24, 2018 23:30
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 Gondlir/b306df903d4ad5dd2ccdc329ccb2fa77 to your computer and use it in GitHub Desktop.
Save Gondlir/b306df903d4ad5dd2ccdc329ccb2fa77 to your computer and use it in GitHub Desktop.
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