Best way to create a trail? [SOLVED]

Omniso

  • Posts: 128
I have an actor that moves and turns at high speed while repeatedly (every 0.02 sec) creating a stationary trail actor (small 9x5 actor with "simple" physics, "cannot move", and no collision boxes). The moment this trail actor is created its opacity starts rapidly decreasing until 0. once its opacity is 0, the actor is killed. This creates a trail behind the main actor no matter what direction it's moving on screen. The problem is that this trail causes FPS to drop due to the amount of actors at once. I tried changing physics to minimal which completely eliminated the lag, but prevented the trail actors from quickly fading out and dying (apparently opacity cannot be changed with minimal physics) and then a severe FPS drop is soon to follow. Is there a way to create a trail without causing FPS to suffer?

« Last Edit: March 07, 2018, 05:26:18 pm by Omniso »

squeeb

  • Posts: 1349
i have many trails that i have made.. no lag... make a number attribute and +1 to it every time the actor is created.. then -1 when it dies.. and draw the attribute to screen so you can see how many actors you have at any given time.. then you can see how many you can have before lag. you may have more than you think.. also.... screen shot code?
heres the game with 4 trails
https://play.google.com/store/apps/details?id=com.fpp.ballzvssquarez



Omniso

  • Posts: 128
Within a few seconds 400+ of these trail actors cause the game to lag.

@DeckBlack Yeah, exactly like that.

squeeb

  • Posts: 1349
Ahh... i think i read that the effects can cause lag.. or removing them... try taking the effect out and  see if you can have more.. the opacity like that may cause some lag also... 400 seems like a lot.. you have 400 trail actors executing  that updating code at 100 times per second.. that may be too much.. do you need that many?.. hmm. Theres some optimizations to be made for sure

DeckBlack

  • Posts: 159
Is Opacity an attribute? If Yes, then I don't see in the code equating this attribute to a real Opacity. Are you sure that all of your Trail are destroyed and do not remain invisible?

JeffreyDriver

  • Posts: 1692
Actors aren't the way to approach this due to performance issues. Use the Image API instead. It's quite an advanced topic though.

See the attached image.

You can see the effect in action in the Dogfight mini game - http://www.stencyl.com/game/play/37229
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

squeeb

  • Posts: 1349
Ahh. Nice!  JeffreyDriver.  I haven't tried  to use image api yet... Can you get 400 working?  Is there a comparison between simple actors and image instances?

Omniso

  • Posts: 128
@squeeb I removed the effect, same results. Technically yes, because there are 5 of these main actors and they act as homing projectiles, lasting no more than 3 seconds before dying.

@DeckBlack Yes, I'm sure. I even did a test run by keeping track of how many trail actors were present. The moment they all faded out the count went to 0 (from the highest being 487)

@JeffreyDriver in the process of trying this


Omniso

  • Posts: 128
Jeffrey, you sir, are a miracle worker. . . Problem solved! Thanks!

« Last Edit: March 07, 2018, 05:34:03 pm by Omniso »

squeeb

  • Posts: 1349
Jeffrey, you sir, are a miracle worker. . . Problem solved! Thanks!
image api work better!!??

JeffreyDriver

  • Posts: 1692
Ahh. Nice!  JeffreyDriver.  I haven't tried  to use image api yet... Can you get 400 working?  Is there a comparison between simple actors and image instances?

I've had 1000's of image instances working.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

squeeb

  • Posts: 1349
I've had 1000's of image instances working.
Perfect! I'll  switch mine over!

bubbadubc

  • *
  • Posts: 34
Trying to implement this literally causes my computer to crash. I'm not sure what I'm doing.
I simply want to create a trail effect behind my player

merrak

  • *
  • Posts: 2010
Trying to implement this literally causes my computer to crash. I'm not sure what I'm doing.
I simply want to create a trail effect behind my player

Show us the code you're using. Logs would be helpful to, if you got any before the crash