- Home /
This question was
closed Jul 18, 2014 at 08:57 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Question by
ShadowSnake141 · Jul 18, 2014 at 08:55 PM ·
c#2djavascriptuce0001
; expected. Insert a semicolon... C# & JavaScript 2D Controller
I'm trying to write a 2D Character controller scipt following the Unity Live 2D Character conrtoller tutorial. He's using C# and I'm using JavaScript. I'm trying to translate his script into JavaScript but clearly some mistakes still remain. Can you help me?
#pragma strict
var maxSpeed : float = 10;
var facingRight = true;
function Start () {
}
function FixedUpdate () {
var flip = function(){
facingRight - !facingRight; //flip the char
var theScale : Vector3 = Transform.localScale; //get local scale
theScale.x *= -1; //flip local scale
Transform.localScale = theScale; //make the flip the new localScale
}
var move: float = Input.GetAxis ("Horizontal"); //get the direction we are moving in
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D.velocity.y); //make move speed float to the max speed
if(move > 0 && !facingRight){
flip();
//if you are moving right and you are not facing right flip it.
}else if(move < 0 && facingRight){
flip();
//if you are moving left and you are not facing left flip it.
}
}
Comment
Follow this Question
Related Questions
Particle System On Key Press 2 Answers
WebGL build is getting cached in the browser, users cannot see updates... 0 Answers
2D Sprite animation JS to C# 2 Answers
Destroy Object On Collision? 3 Answers