Question by
karoles357 · Mar 30, 2018 at 02:26 PM ·
errormovement script
Tap to move +20 X Unity 2D
Hello! Its my script to move, but I need to get +20 X in one touch. How can I do this in Unity 2D?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class MoveScript : MonoBehaviour {
float directionX;
public float moveSpeed = 5f;
Rigidbody2D rb;
void Start ()
{
rb = GetComponent<Rigidbody2D> ();
}
void Update ()
{
directionX = CrossPlatformInputManager.GetAxis ("Horizontal");
}
void FixedUpdate()
{
rb.velocity = new Vector2 (directionX * moveSpeed, rb.velocity.y);
}
Comment
Your answer
Follow this Question
Related Questions
Compiler error 0 Answers
When i type code to move my person i get errors 1 Answer
Can't Make Character Jump 0 Answers
How can I solve that problem with "Shader Graph"? 0 Answers
Creating projectile prefab that points at the mouse 0 Answers