Hi everyone ive got a problem with HingeJoints... I want to activate the hinge joint motor via script but i dont get access to the variables. The script is attached directly to the object( in this case its a door). This is the error Log: /HoH_DoorOpener.cs(51,24): error CS1612: Cannot modify the return value of `UnityEngine.HingeJoint.motor' because it is not a variable
I dont know what to do to access theese variables. If enyone could help me i would be very happy :)
using UnityEngine;
using System.Collections;
public class HoH_DoorOpener : MonoBehaviour
{
public int sizeX = 50;
public int sizeY = 50;
public float iAppearDistance = 3;
public Transform FPSPlayer;
public Texture2D HandSymbol;
Vector3 mousePos = new Vector3(0, 0, 0);
float fDistance = 0;
bool doWindow = false;
void Update()
{
fDistance = Vector3.Distance(transform.position, FPSPlayer.position);
print(fDistance);
if (fDistance <= iAppearDistance)
{
doWindow = true;
}
else
{
doWindow = false;
}
if (Input.GetMouseButton(0) && doWindow)
{
//Here is the problem, where i cant access the variables...
hingeJoint.motor.force = 10;
hingeJoint.motor.targetVelocity = 10;
hingeJoint.motor.freeSpin = true;
print("Opening Door...");
}
if (Input.GetMouseButton(1) && doWindow)
{
//similar problems at this point ^^
print("Closing Door...");
}
}
void OnGUI()
{
if (doWindow)
{
GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, sizeX, sizeY),
HandSymbol);
}
}
}