Why do I get this error: “Assets/Scripts/Parkour Movement.cs(15,38): error CS0119: Expression denotes a type', where a
variable’, value' or
method group’ was expected” with these lines?:
private bool surfaceNormal = Vector3;
private bool myNormal = Vector3;
Thanks for your help. Sorry for such a basic question. I couldn’t use new or var because this is under “public class ParkourMovement : MonoBehaviour {”
Thanks again.
EDIT:
So after applying the fix below, I know have 28 more errors because my script is a mess after a conversion from Java script. Any help would be greatly appreciated! Thanks!
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(CharacterController))]
public class ParkourMovement : MonoBehaviour {
public float moveSpeed = 6.0f; // Movement speed
public float turnSpeed = 90.0f; // Turning speed in degrees per second
private float lerpSpeed = 10.0f; // Smoothing speed
public float gravity = 10.0f; // Gravity acceleration
float deltaGround = 0.2f; // Character is grounded up to the distance
public float jumpSpeed = 10.0f;
public float jumpRange = 10.0f;
bool isGrounded;
private Vector3 surfaceNormal = new Vector3(1,2,3);
private Vector3 myNormal = Vector3.f;
private float distGround;
bool jumping = false; // Flag for jumping to the wall
private float vertSpeed = 0.0f; // The current speed of the Vertical Jump
// Use this for initialization
void Start () {
myNormal = Transform.up; // Normal starts as the up direction of the character
rigidbody.freezeRotation = true; // Disables the rotation via physics
distGround = collider.bounds.extents.y - collider.center.y; // Distance from transform.posistion to the ground
}
void FixedUpdate() {
rigidbody.AddForce (-gravity * rigidbody.mass * myNormal); // Apply constant weight force according to character normal
}
// Update is called once per frame
void Update () {
// Jump Code - Jump to wall or simple Jump
if (jumping) return;
var ray = Ray;
var hit = RaycastHit;
if (Input.GetButtonDown ("Jump")) { // If the player is pressing jump...
ray = Ray(transform.posistion, transform.forward);
if (Physics.Raycast(ray, hit, jumpRange)) { // Checks to see if there is a wall
JumpToWall(hit.point, hit.normal); // Yes Jump to the wall
} else {
if(isGrounded) { //no; if grounded, jump up
Rigidbody.velocity += jumpSpeed * myNormal;
}
}
// Movement Code - Turn left/right with Horizontal Axis
Transform.Rotate(0, Input.GetAxis ("Horizontal") * turnSpeed * Time.deltaTime, 0); // Update the surface noraml and isGrounded
ray = Ray(Transform.posistion, -myNormal); // Cast a ray downwards
if (Physics.Raycast(ray, hit)) {
isGrounded = hit.Distance <= distGround + deltaGround;
surefaceNoraml = hit.normal;
} else {
isGrounded = false;
surfaceNormal = Vector3.up; // Assumes that the noraml is up to avoid some weird shit
}
myNormal = Vec.Lerp(myNormal, surfaceNormal, lerpSpeed * Time.deltaTime);
var myForward = Vector3.Cross (Transform.right, myNormal); // Finds the forwards direction with my normal
var targetRot = Quaternion.LookRotation (myForward, myNoraml); // Alligns the character to the new myNormal whilst keep the same forward Direction
Transform.rotation = Quaternion.Lerp (Transform.rotation, targetRot, lerpSpeed * Time.deltaTime);
Transform.translate (0, 0, Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime);
}
}
}