Spawning actors, mega jump style

joelloydjoelloyd Member, PRO Posts: 119

I seem to be having a problem spawning coins in set positions and distances apart making shapes with the coins and structure. Currently i spawn coins in line of 5s on different x positions to test it out. Depending on what speed my character is going these distances apart are varying, the faster my character is going (being boosted for example), the wider the gap is apart. Are my coins when being spawned taking a certain amount of time to kick in and then they move down? Also to note, my coins move down at the 'Main player liner velocity /400'. So as the players liner velocity is going up, im saying every 10 spawn a coin at x position.

if anyone can help with a way to keep spawned actors structured, would be so helpful.

thanks

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Spawning an actor does take a very tiny bit of time, but that is probably not an issue in this case.

    If I am reading your question correctly, the main challenge is probably that you are basing the spawn event not on distance but on velocity. And because velocity is variable, your spawn points are varying as well.

    You have two choices:

    1) If you continue to use the player's linear velocity (which is distance over time) in calculating a coin's placement, you will need to compensate by decreasing/increasing the time that coins are spawned. (Instead of every 10 seconds, you will need to increase/decrease the time by a ratio of the player's linear velocity.)

    2) If you use distance (instead of velocity) then you can use straight x,y coordinates.

    Basing coin placement on pure distance takes time out of the equation. (Velocity puts it back in again.)

  • joelloydjoelloyd Member, PRO Posts: 119

    Good point @RThurman ! How do I use distance in the correct way? So currently I'm using the score the set the time for when an actor is spawned. The score is made but saying, score=linar velocity /400 and every 10 spawn. But without having to make a crap load of actors and keep them just of screen which I could do but takes time. How would I say when coin is - 30 y spawn next coin.

    If that made sense, thanks

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited August 2015

    I suppose that everyone has their own preferences for how to do it. My preference is just to brute force it.

    I would create a boolean attribute called something like "trigger-S". Then whenever I wanted to create an "S" pattern. I would just change "trigger-S" to true.

    Then I would have a rule that says when "trigger-S" is true -- spawn 20 coins in an "S" pattern. (I would literally use 20 spawn behaviors that would have their coordinates set to create an "S" pattern just above the top of the scene.)
    Then set "trigger-S" back to false so it waits until next time.

    (Later on you can get all fancy with creating patterns with loops and trig. But for now, I would just brute force it.)

  • joelloydjoelloyd Member, PRO Posts: 119

    I will try spawning in an existing shape but how far out of the display can I spawn, iv tried this before and when I went over 400 out of the display nothing spawns. Cheers, huge help so far! Thanks

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Yes, actors are automatically destroyed when they get beyond 400 (or is it 500?) pixels outside the scene. You can fix this if you make the scene size bigger. Just make it 1000 pixels tall (but keep the camera down at the bottom of the scene) and you won't need to worry about it.

  • joelloydjoelloyd Member, PRO Posts: 119

    I'll have a try making everything under 500 pixels in size and just work around it. I can't make the scene size bigger because it is already 3 times the size and I tried once to constrain the camera once it got to a certain height and it had silly effects so I just had to leave the camera to hit the top on the display.

    Thanks so much though, help me a lot! Legend

  • wayback_gamerwayback_gamer USMember, PRO Posts: 124

    this helps answer some questions

Sign In or Register to comment.