Hi,
I am sorry for my stupid first question. I am very noobish to unity-scripting.
Before Unity, I have only programmed in Flash and Javascript, which works mainly with one single file. Now, here are so many files, which confuses me a bit.
I simply have the question, how to call a function from an other class.
Meaning:
I have one script, which contains a function, that I want to call from different scripts. Lets say, this is the class with the function I would like to call:
using UnityEngine;
using System.Collections;public class patsch : MonoBehaviour { public void laerm(){ print("Lärm"); } }
And I have an other script like this (attached to a rigidbody):
using UnityEngine; using
System.Collections;public class faden : MonoBehaviour {
void OnMouseDown() {
float rnd = Random.Range(-50,50);
rigidbody.AddForce(0,0,100);
rigidbody.AddTorque(0f,rnd,0f);// I would love to call my function on this place } }
How do I do this?
Regards
Chricken