Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

'OpenClose' is not a member of 'Pushpull' Javascript help

$
0
0
Hey all, I'm trying to learn to code a Jedi type of force code that allows the pushing and pulling of objects. I'm just having trouble with what I guess is a pretty easy fix. This is the code for the object: #pragma strict public var relativeOpenPos = Vector3(1,0,0); public var speed = 1.0f; private var posOpen; private var posClose; private var posDest; private var open = false; function Start() { posClose = transform.position; posOpen = transform.position + relativeOpenPos; posDest = posClose; } function Update() { var pos = Vector3.MoveTowards(transform.position, posDest, Time.deltaTime * speed); rigidbody.MovePosition(pos); } function OpenClose() { open = !open; posDest = open ? posOpen : posClose; } and this is the code for the player: #pragma strict function Update() { var hit : RaycastHit; var ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast(ray, hit) && (hit.collider.tag == "PushPull")) { hit.collider.GetComponent(PushPull).OpenClose(); } } } The title says it all, I'm getting problems with them not being members of each other. Thanks in advance!

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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