GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2010-10-10 03:23:27

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

A little something I figured out about instance_place()

Hi guys. Again, I did some speed testing with gm and I found something interesting about instance_place(). I tested the fonction repeated about 100k times with a circle checking for instance (squares) placed at position (x,y). First I did the test with 1 square. And then with multiple square randomly placed around the room. Then the result that came out was pretty damn fast (about 200ms with 1000 squares around the room). Then I tried to place 1000 squares on the top left corner where noone touched the circle and the time taken went up to a crazy 7k ms which is a very big increase compared to the randomly placed test.

Finally, I figured out that once the fonction instance_place has found one instance it stops right away. That might be insignificant but it can be useful in many situations. Now that we know that it is very slow when there are no collisions, we have to make sure to not use it too often during the game to check for collisions. However, if you're sure it will encounter an instance than you can use it a little bit more.

I hope this was useful.

Mig

Offline

Board footer

Powered by FluxBB