Hey there.
First of all I’m quite a noob, so please be patient with me…
I’m currrently working on a jump game quite similiar to Doodle Jump.
My problem is that I want to enable a specific script as soon as the game character passes the same line as where a platform is located. So it doesn’t have tobe the case that the player gets in touch with the platform.
I tried to get and compare the position coordinates of the two objects and then wanted to check if they are equal and if this was the case, the script should be enabled.
I’ve spent lots of time with it already, but I still don’t have a solution for this.
So please please help me!
Here is the code that should enable the other script:
using UnityEngine;
using System.Collections;
public class enableScript : MonoBehaviour {
private Transform othertransform;
private Transform player;
void Awake() {
float othertransform = GameObject.FindWithTag("MainCamera").transform.position;
float player = GameObject.FindWithTag ("Player").transform.position;
}
void Update () {
if (othertransform == player) {
(gameObject.GetComponent( "DestroyPlatform" ) as MonoBehaviour).enabled = true;
}
}
}
Then this is the code that should be enabled:
#pragma strict
var othertransform : Transform;
function Awake() {
othertransform = GameObject.FindWithTag("MainCamera").transform;
}
function Update () {
if (Vector3.Distance(transform.position, othertransform.position) > 20) {
Destroy(this.gameObject, 5);
}
}
and finally this is what the interface of the game looks like (the camera follows the player just on y-axis btw):

Thank you a lot for your help in advance!