- Home /
Error Java script
I have script for walking and jumping This is link for that http://pastebin.com/raw.php?i=1x3r0RBn
I have 4 errors 1. Assets/My assets/Skript/PlayerMovementScript.js(68,1): BCE0044: expecting }, found ''. 2. Assets/My assets/Skript/PlayerMovementScript.js(61,11): BCE0044: expecting (, found 'OnCollisionExit'.
3.Assets/My assets/Skript/PlayerMovementScript.js(55,2): BCE0044: expecting ), found 'grounded'. 4.Assets/My assets/Skript/PlayerMovementScript.js(50,26): BCE0043: Unexpected token: collision.
Answer by robertbu · Aug 26, 2014 at 10:54 PM
Though the compiler is only listing 4 errors, you have a lot more than 4 errors. I did a quick pass to get your script to compile. You'll have to figure out any logic problems. For future posts, please past your code into your question, select your code and use the 101/010 button to format. Also proper indentation makes the code easier to read, and in this case, would have made your first error jump out at you.
var acceleration : float = 10;
var deacceleration : float = 10;
@HideInInspector
var deaccelerationX : float;
@HideInInspector
var deaccelerationZ : float;
var jumpVelocity : float = 400;
@HideInInspector
var grounded : boolean = false;
var maxslope : float = 60;
var cameraObject : GameObject;
var maxSpeed : float = 25;
@HideInInspector
var movement : Vector2;
function Update()
{
movement = Vector2( rigidbody.velocity.x, rigidbody.velocity.z);
if ( movement.magnitude > maxSpeed)
{
movement = movement.normalized;
movement *= maxSpeed;
}
rigidbody.velocity.x = movement.x;
rigidbody.velocity.z = movement.y;
if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0 && grounded)
{
rigidbody.velocity.x = Mathf.SmoothDamp(rigidbody.velocity.x, 0, deaccelerationX, deacceleration);
rigidbody.velocity.z = Mathf.SmoothDamp(rigidbody.velocity.z, 0, deaccelerationZ, deacceleration);
}
transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLook).currentYRotation, 0);
rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * acceleration * Time.deltaTime, 0, Input.GetAxis("Vertical") * acceleration * Time.deltaTime);
if(Input.GetButtonDown("Jump") && grounded)
{
rigidbody.AddForce(0, jumpVelocity,0);
}
}
function OnCollisionStay(collision : Collision)
{
for (var contact : ContactPoint in collision.contacts)
{
if(Vector3.Angle(contact.normal, Vector3.up) < maxslope)
grounded = true;
}
}
function OnCollisionExit()
{
grounded = false;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613161623im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UnityScript error in transform.Position 2 Answers
Can you help with my errors? All are similar... 1 Answer
Why are these errors messing with me? 2 Answers
syntax errors 1 Answer