Layer Depth Assignment From An Object To Another [SOLVED]

Z

Zephyr Schwarzwolf

Guest
Hi everyone !

I have two objects :

- The first one is the one the player controls. Named "PLAYER".

- The second one is an object (rather a group of objects) distributed on several layers. Each layer has its own depth and each object from that group take the depth of the layer on which it has been set. Named "DEPTH_LEVEL".

When my first object collide with one of them, I want him to take their depth. But it doesn't work...
I tried that simple code :

Code:
if (place_meeting(x + hspd, y + vspd, DEPTH_LEVEL))
{
    depth = DEPTH_LEVEL.depth;
}
Any ideas ? Thank in advance.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You don't want to set the depth, you want to set the layer (and the instance will inherit the depth of the layer it's assigned to). You also want to use "instance_place" to get an ID value rather than using the object index for assigning the value, like this:

Code:
var _inst = instance_place(x + hspd, y + vspd, DEPTH_LEVEL);
if instance_exists(_inst)
{
   layer = _inst.layer;
}
 
Z

Zephyr Schwarzwolf

Guest
Thank you sooo much ! That's perfect for what I want to do ! But, I have one more question :
I don't know if it's possible to check a FULL collision. For example, if my collision zone is a square, my object won't only have to be in contact with, but it'll have to be perfectly IN the square (No matter if it does "normal" collisions with other objects).
How to do that ?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You can use the "rectangle_in_rectangle" function for that. :)

The code is slightly more complicated but something like this should be fine:

Code:
var _inst = instance_place(x + hspd, y + vspd, DEPTH_LEVEL);
if instance_exists(_inst)
{
if rectangle_in_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom, _inst.bbox_left, _inst.bbox_top, _inst.bbox_right, _inst.bbox_bottom) == 1
    {
    layer = _inst.layer;
    }
}
Note that the above code assumes that both instances have a sprite assigned to their sprite_index. If they don't then simply set the values to those that you require for each of the rectangles.
 
Z

Zephyr Schwarzwolf

Guest
Could you edit your thread title to be normal case like everyone else?
All caps is just obnoxious, I'm surprised @Nocturne didn't mention it.
Is it a reason to be distasteful ? I do not understand where is the problem... That's just more visible and clearer. I see nowhere a rule that says "Titles all in uppercase are forbidden". Others can do same, it doesn't bother me.
Moreover, let me tell you I'm new here. I'm not used to all these "conventions", like you. You could be more indulgent.
I did not disrespected anyone here, please do the same.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
That's just more visible and clearer. I see nowhere a rule that says "Titles all in uppercase are forbidden".
Aaaaaaaaaaaactually....
Please do not:
  • ...
  • Post in all CAPS or use excessive color, bold or large text, or special fonts. Instead use them sparingly for emphasis.
  • ...
:D

And I didn't say anything because it was a topic title and not the main post, and as a new user it didn't seem that important... If all their topic titles are in caps, I'd say something... And yeah, sorry @rIKmAN , your reply could of been worded better. ;)

No harm done though and the topic is solved, so yay me!

:bunny:
 
Z

Zephyr Schwarzwolf

Guest
Aaaaaaaaaaaactually....

:D

And I didn't say anything because it was a topic title and not the main post, and as a new user it didn't seem that important... If all their topic titles are in caps, I'd say something... And yeah, sorry @rIKmAN , your reply could of been worded better. ;)

No harm done though and the topic is solved, so yay me!

:bunny:
I guessed his point. It could have been seen as unfair to set titles as such "standing out" but I really felt like if I had done something unforgivable ! :confused:
But effectively, no harm done then I edited it ! :p And, I know the usage, for now !
 

rIKmAN

Member
Is it a reason to be distasteful ? I do not understand where is the problem... That's just more visible and clearer. I see nowhere a rule that says "Titles all in uppercase are forbidden". Others can do same, it doesn't bother me.
Moreover, let me tell you I'm new here. I'm not used to all these "conventions", like you. You could be more indulgent.
I did not disrespected anyone here, please do the same.
I know you're new here as I saw your post count, and it's one of the reasons I mentioned it, so you could start as you mean to go on.
I also would have thought seeing every other thread written normally might have been a hint as to how to title your own threads, but it didn't so I pointed it out to you.

With regards to "conventions", this is true of all forums on the entire internet, not just here, and I don't believe that in 2018 you have never seen or used a forum or similar website.
Think of it like this: if you were asking someone a question would you start shouting in their face, or just speak like a normal person?

If you think me pointing how to use a forum like everyone else and stick to the rules is disrespectful then that's upto you.
I actually think you posting in all caps, not reading the rules, then arguing an all caps rules doesn't exist and getting upset when someone points out your error is more disrespectful - but that's just me. ¯\_(ツ)_/¯

I guessed his point. It could have been seen as unfair to set titles as such "standing out" but I really felt like if I had done something unforgivable ! :confused:
But effectively, no harm done then I edited it ! :p And, I know the usage, for now !
I never said or hinted you had done something unforgivable, please stop with the drama.
I pointed out that you shouldn't use all caps in thread titles, that's all.
your reply could of been worded better. ;)
Maybe - that's what a week of new users posting "my connection doesn't work" threads over and over will do to you, despite there being 4 already on the first page.
But then so could the title of the thread.. ;)
(and no harm done at all, just an overreaction)
 
Last edited:
Z

Zephyr Schwarzwolf

Guest
With regards to "conventions", this is true of all forums on the entire internet, not just here, and I don't believe that in 2018 you have never seen or used a forum or similar website.
Think of it like this: if you were asking someone a question would you start shouting in their face, or just speak like a normal person?
You can believe me or not, but that's the first forum on which I register. I'm not a regular of forums or social networks.
And I didn't think uppercases could be like if I was shouting something in someone's face (Sorry if you felt like it was the case). We've got something specialy used to do that ---> !
Anyway, no offense, only titles, I changed them. ^^ Meh.
 
Top