Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

"jump" Is not a member of object?

$
0
0
So... I have a GUI on screen that when clicked will trigger the "Jump" method on my character: var player : GameObject; var script; function Start(){ player = gameObject.FindWithTag("Player") ; script = player.GetComponent(Move) as Move ; } function OnMouseDown() { script.jump(); } The player var is the character, and there's a script on it called Move (EXACLTY Move, I made sure that it wasn't just some stupid capitalization thing): var speed : float = 6.0; var jumpSpeed : float = 8.0; var gravity : float = 20.0; private var moveDirection : Vector3 = Vector3.zero; function Update() { var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) { // We are grounded, so recalculate // move direction directly from axes moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if (Input.GetButton ("Jump")) { moveDirection.y = jumpSpeed; } } // Apply gravity moveDirection.y -= gravity * Time.deltaTime; // Move the controller controller.Move(moveDirection * Time.deltaTime); } function moveforward(){ var controller : CharacterController = GetComponent(CharacterController); controller.Move(-Vector3.back / 6); } function moveback(){ var controller : CharacterController = GetComponent(CharacterController); controller.Move(-Vector3.forward / 6); } function moveleft(){ var controller : CharacterController = GetComponent(CharacterController); controller.Move(-Vector3.left / 6); } function moveright(){ var controller : CharacterController = GetComponent(CharacterController); controller.Move(-Vector3.right / 6); } function jump(){ var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) { moveDirection.y = jumpSpeed; controller.Move(moveDirection * Time.deltaTime); } } (The first part of the script is for keyboard, but this is an android app, and I use the keyboard for debugging) There are also similar buttons to the first script mentioned, but the names of the script.jump(); vary. They all don't work, and, yes my let and right are switched, that's intended. They all give the error: "jump is not a member of object. (On the line with script.jump();)" it was working before, but then I changed it from windows to Android and BAM stoppped working. This is in java BTW. I have also tried reimporting all, restarting, all that.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>