- Home /
The question is answered, right answer was accepted
BCE0019 when using functions
Can someone explain what is wrong with this script? I'm getting the error message: "Assets/Movement.js(38,36): BCE0019: 'point' is not a member of 'Object'. "
#pragma strict
var SomePrefab: Transform;
var dest : Vector3;
var up : Vector3;
var lookdest : Vector3;
var going : Vector3;
var direction : Vector3;
var directionreduced : Vector3;
var getgoingswag : Vector3;
var destdown : Vector3;
var ObjectHit : String;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
if(Input.GetKey(KeyCode.Mouse0)){
var hit : RaycastHit;
var ray : Ray = camera.main.ScreenPointToRay (Input.mousePosition);
Physics.Raycast(ray, hit);
Debug.DrawRay (ray.origin, ray.direction*20, Color.blue);
ObjectHit = hit.collider.gameObject.tag;
if (hit.rigidbody != null){
MovementSet(hit);
}
}
lookdest = new Vector3(dest.x, transform.position.y, dest.z);
transform.LookAt(lookdest);
going = (dest - transform.position)/100;
direction = new Vector3(going.x,0,going.z);
var traject : Ray = new Ray(transform.position, direction);
Debug.DrawRay (traject.origin, traject.direction*10, Color.yellow);
directionreduced = (traject.GetPoint(10)-transform.position)/100;
getgoingswag = new Vector3(directionreduced.x,-1,directionreduced.z);
if (((Mathf.Round(transform.position.x)) != (Mathf.Round(dest.x)))||((Mathf.Round(transform.position.z)) != (Mathf.Round(dest.z)))){
controller.Move(getgoingswag);}
}
function MovementSet (hit){
dest = hit.point + up;
var hit2 : RaycastHit;
var ray2 : Ray = new Ray(dest+Vector3(0,0.1,0),Vector3(0,-1,0));
Debug.DrawRay (ray2.origin, ray2.direction*20, Color.black);
Physics.Raycast(ray2, hit2);
destdown = hit2.point;
if(Input.GetKeyDown(KeyCode.Mouse0)){
Instantiate(SomePrefab,destdown,Quaternion.identity);
}
}
Did you try:
function $$anonymous$$ovementSet( hit : RaycastHit) ?
Ah, I see what I did wrong. That worked thanks. I'd tried hit : RaycastHit but I put that as in the wrong place as well.
Follow this Question
Related Questions
The name `PurchaseManager' does not exist in the current context 0 Answers
How do I call a function containing a while loop, inside the update function? 2 Answers
get nearest instance of game object 1 Answer
NullReferenceException: Object reference not set to an instance of an object 1 Answer
Function action applies to every object that have script with that function on it. Help please 1 Answer