Hey! :o
I’m having a little trouble here, I have a Prefab with a script attached.
The code is the default "moving platform" script from the 2D Platformer.
It looks like this:
var targetA : GameObject;
var targetB : GameObject;
var speed : float = 0.1;
function FixedUpdate () {
var weight = Mathf.Cos(Time.time * speed * 2 * Mathf.PI) * 0.5 + 0.5;
transform.position = targetA.transform.position * weight
+ targetB.transform.position * (1-weight);
}
This gives me two target options to insert in the Unity Inspector. (Target A, and Target B)
Because it is a Prefab I can only add “existing” objects to it, in other words no empty gameobjects created in Unity. (I think it goes like this because I cant seem to add those empty gameobjects. :P)
But when I play the scene with those prefabs being spawned, (They spawn on the same position as the Target A)
They however don’t move to Target B. They just instantly flash to 0, 0, 0 on the game-field.
Anyone knows what causes this? I know it is in the above script because when I remove the script it just stays on top op Target A.
Thank You!
- Tim