Jump to content


Photo

Move/re-use objects or delete and re-create?

gm:studio

  • Please log in to reply
2 replies to this topic

#1 jtaylor

jtaylor

    GMC Member

  • New Member
  • 2 posts
  • Version:GM:Studio

Posted 29 March 2016 - 12:08 AM

I'm making a top-down snowboarding game with trees (objects) outlining the course. I'm using physics with the trees so the player will bounce off. I've tried three options:

1) When the room is created, line the sides of the course with trees. However, that's a lot of objects and the game slows down for longer levels.

2) Create trees just before they enter the bottom of the view and delete just after they leave the top, but I still experience a significant slowdown vs. option (1) with shorter levels

3) Re-use the tree objects by moving them to just below the bottom of the view after they leave the top, so it's not constantly destroying and creating instances of the same objects. This turned out to be by far the slowest. I had a step event for the tree object checking if it was above the view and then moving it to the next position below (stored in an array when the level is created).

 

Any advice on how to do this better? I'm hoping I'm missing something obvious because this doesn't seem like it should be this hard to get decent performance on a 2D game.


  • 0

#2 billybobjoe556

billybobjoe556

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM8.1

Posted 29 March 2016 - 12:35 AM

Put the bouncing code player sided instead of tree sided. Are you using gamemakers built in physics? If so, what is the code and physics properties on the tree?

 

Lots of objects performing physics calculations by the frame would definitely make it hard to get decent performance.


  • 0

#3 jtaylor

jtaylor

    GMC Member

  • New Member
  • 2 posts
  • Version:GM:Studio

Posted 29 March 2016 - 12:48 AM

Put the bouncing code player sided instead of tree sided. Are you using gamemakers built in physics? If so, what is the code and physics properties on the tree?

 

Lots of objects performing physics calculations by the frame would definitely make it hard to get decent performance.

I'm using the built-in physics. The collision event is in the player object and only contains an update to the player's health based on the speed and angle of the collision. There's no code for the tree object (aside from when I tried options 2 and 3 above, but that has nothing to do with collisions).


  • 0





Also tagged with one or more of these keywords: gm:studio