devster's Forum Posts

  • 7 posts
  • I wasn't sure about what section to put this question in, so i'll put it in here, sorry if i'm wrong:

    this is more of just a general game dev question that has been bothering me.

    let's take this scenario:

    We have Sprite1 (player) and multiple instances of Sprite2 (scenery).

    when Sprite1 touches Sprite2 = perform action on Sprite2.

    That is simple, but i was thinking about the best, most optimized way to do this, regarding performance (in a situation where there is a lot of instances of Sprite2).

    i started thinking different ways to check this condition. for example, which is usually more efficient, distance check or collision check?

    say, if i disable all collision for Sprite2, and instead, use a distance check, like "distance between Sprite1 and Sprite2 is less than X = perform action on Sprite2". this is all assuming that the collision wouldn't need to be pixel perfect to begin with. and is there even more clever way to do this kind of check, for example to isolate and only check those instances (Sprite2) that are very close to the player (Sprite1)?

    i guess it's really apparent that i'm not a very experienced dev, so i apologise if this is a silly question. i just simply want to learn more about efficient ways to do things, and performance is something that is always on my mind. anyway, thanks for reading and for any possible tidbits of knowledge for this.

  • Thanks for replying!

    this works, BUT it won't work in a situation where the top object is moving, for example sliding on top of the bottom object, because in this case it will stop. i could perhaps store the velocity X + Y in variables to circumvent this, but i would like to have a bit more unintrusive way to do this. basically letting the top object just mind it's own business, intact, whatever it is doing on top of the bottom object.

    is there any other way to refresh the collision?

    (i did find another way around this: make a second animation frame for top object, shrink the collision box just a tiny bit, then set the frame after (or before) disabling collision. it works but again, it is kinda hacky method, and i would still like the top object be intact, in its original form)

  • I'll try to keep this short and simple, i tried to search, but didn't find anything, but maybe this is something really simple:

    so, two physics objects, on top of each other. the bottom one immovable, the other one resting on top of the bottom one. i click a mouse button and i want to disable physics collision between the two objects so that the top object falls through the bottom one, but nothing happens. they keep colliding. i tested stuff and i came to the conclusion that the -disable physics collision- action does not work if the objects are already colliding.

    is it me not getting something obvious, or is it just the nature of the beast? and more importantly, is there any (simple-ish) way around this?

  • so, instead of Pick by evaluate, I guess the best option is to use "For Each Sprite order by Sprite.pv descending"

    and then stop the loop when loopindex is 1.

    hmm, i'm not sure if i understand what you mean by the loopindex.

    could you post an example about this as a pseudo code or such?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • sorry, i'll try to elaborate. basically i just want to pick the second highest value of the private variable, at any given point. i can't simply pick a number, because the private variable value is constantly changing.

    is it something like:

    -pick sprite instance with highest value

    -- sprite.value equals sprite.(pv) -1

    ?

  • Sorry it took me a while to reply. yes i got it working. it was surprisingly straightforward. i remember it being a bit more complex on the old construct classic.

    i'm not sure if i should spam and post a new topic or not, so i'll just ask here:

    again, i have a sprite with multiple instances, each having increasing private variable value(1,2,3,4,5 and so forth). how can i interact between two instances that have the highest values? for example, between instances with values 12 and 13, 7 and 8, 23 and 24 and so forth? how do i pick those?

  • hey. trying out construct3 demo. i have previous experience from the original construct classic. my question is difficult to explain, but i'll try my best:

    so, i have a sprite1. then i have a sprite2. sprite1 has 3 image points. on level start, i want to spawn 3 instances of sprite2, and always set their position to sprite1, on their own image points. so far so good, i can do that.

    but, i also need to have multiple instances of sprite1, and thats where everything goes messy. i get weird results, like sprite2 only being correctly placed on one instance of sprite1 but the others are not showing correctly, for example only being set on a single image point or not at all, depending on what i try.

    what would be the correct way to do this? honestly it's probably something simple but i'm just lost on this one. trying to manipulate multiple instances of an object always makes my brain fart hard.

  • 7 posts