Post by acorrow on Apr 17, 2015 20:41:29 GMT
So I seem to be having a hard time grasping Triggered Spawners. Perhaps I'm just not looking at this correctly, or I'm just not understanding the wave in general.
I actually have 2 problems, one with the spawner, and one with the object. Lets start with the spawner. PREFACE, these are all 2D objects, I'm too lazy to write 2D at the end of everything... I'm using a GameObject with a Circle Collider and a Triggered Spawner. The collider is offset so that the game object is in the water, and the trigger is on the land. So when the player enters the collider (its a Trigger) I have the triggered spawner event set to TriggerEnter2D, and you enter, and it spawns my fish. Excellent. However, I can't make this repeat. If I exit the trigger and enter back in, boom, no problem. Spawns my awesome fish and everything is good.
Question: Can I setup a triggered spawner to constantly spawn a prefab while the player is IN the collider/trigger (not just once when they ENTERED the collider)?
Second issue with this. The fish I'm spawning, is a super simple object. Rigidbody, Circle collider, sprite, script. Here is the full on behavior script:
So a very simple script, all it does, is when the object is spawned, launches it up in the air, and it falls back down (into the killzone that kills all killables that fall too long). Simple. HOWEVER, after a while, the fish are spawned and just fall straight down, as if no force was applied. I suspect that the velocity is still set from the last time the pooled fish (pun intended) was spawned/killed, as it was always heading DOWN when caught in the kill zone. This even happens when I set my velocity to zero first thing before applying the force.
Question: When the killable is killed, does the transform.velocity reset? if not, any idea why resetting it like this would have no effect?
Thanks in advance!
I actually have 2 problems, one with the spawner, and one with the object. Lets start with the spawner. PREFACE, these are all 2D objects, I'm too lazy to write 2D at the end of everything... I'm using a GameObject with a Circle Collider and a Triggered Spawner. The collider is offset so that the game object is in the water, and the trigger is on the land. So when the player enters the collider (its a Trigger) I have the triggered spawner event set to TriggerEnter2D, and you enter, and it spawns my fish. Excellent. However, I can't make this repeat. If I exit the trigger and enter back in, boom, no problem. Spawns my awesome fish and everything is good.
Question: Can I setup a triggered spawner to constantly spawn a prefab while the player is IN the collider/trigger (not just once when they ENTERED the collider)?
Second issue with this. The fish I'm spawning, is a super simple object. Rigidbody, Circle collider, sprite, script. Here is the full on behavior script:
public class JumpyFish : MonoBehaviour {
public Sprite UpSprite;
public Sprite DownSprite;
void Start()
{
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 2500));
}
// Update is called once per frame
void Update () {
if (GetComponent<Rigidbody2D>().velocity.y > 0)
{
GetComponent<SpriteRenderer>().sprite = UpSprite;
}else if (GetComponent<Rigidbody2D>().velocity.y < 0)
{
GetComponent<SpriteRenderer>().sprite = DownSprite;
}
}
}
So a very simple script, all it does, is when the object is spawned, launches it up in the air, and it falls back down (into the killzone that kills all killables that fall too long). Simple. HOWEVER, after a while, the fish are spawned and just fall straight down, as if no force was applied. I suspect that the velocity is still set from the last time the pooled fish (pun intended) was spawned/killed, as it was always heading DOWN when caught in the kill zone. This even happens when I set my velocity to zero first thing before applying the force.
Question: When the killable is killed, does the transform.velocity reset? if not, any idea why resetting it like this would have no effect?
Thanks in advance!