- Home /
Question by
MahPentakill · Oct 26, 2015 at 12:02 PM ·
2dsprite2d gamescript error2d animation
Problem with Scrip for sprites
Hi guys, im following the 2D Character Controller tutorial on Unity website and i tried a script for my 2D game. When i compile it, it keeps pointing me out errors that i cant correct. Here is the script:
using UnityEngine; using System.Collections;
public class TLOscriptcontrol : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
void Start ()
{}
void FixedUpdate ()
{
float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D().velocity.y);
if(move > 0 &&!facingRight)
Flip();
else if(move < 0 && facingRight)
Flip();
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = Transform.localScale;
theScale.x *= -1;
Transform.localScale = theScale;
}
}
Comment
Answer by MahPentakill · Oct 26, 2015 at 05:00 PM
I found a solution, i simply used the code of the premade robot boy thingy and replaced my animations instead
Your answer
Follow this Question
Related Questions
Animating a 2D character with this type of sprite 0 Answers
,Is there a Way to Flip 2D-Keyframes? 0 Answers
Best resolution to create sprites at? 0 Answers
Stop jump animation 1 Answer