Collision Masks for every object?
Hi, I have a problem with collision masks in MMF2. In my application I made a customized shoot system, creating objects with a 360º engine. The problem appears when it collides with a backdrop. I made a collision system with fast loops and collision masks, but the collision works only for one of objects, specially the last object created. I tried to compare it with a Spread Value or use the "Pick an object" but it dont works too.
Someone knows how to make Collision Masks works for every of this objects?
Re: Collision Masks for every object?
Maybe, after spreading values on your created objects, run a fastloop "number of objects" times.
Marv
Re: Collision Masks for every object?
This example will probably help you:
http://ultimatewalrus.com/uwexamples/simple_enemies.mfa
It implements collision masks without having to use a separate object.
Re: Collision Masks for every object?
I think that you didn't understand.
The bug is because the Collision Masks of MMF2 works only in one copy of created object (if has more then one in the frame), the collision is detected only in last copy created
I want to know how to make Collision Masks works in all copies of this object.
Re: Collision Masks for every object?
Quote:
Originally Posted by Alves
I think that you didn't understand.
The bug is because the Collision Masks of MMF2 works only in one copy of created object (if has more then one in the frame), the collision is detected only in last copy created
I want to know how to make Collision Masks works in all copies of this object.
Um... I don't know what else to say. The example I gave you has like ten objects all working correctly with collision masks.
Maybe I'm having difficulty understanding what the problem is. Do you think you could upload the MFA?
Re: Collision Masks for every object?
Ok, I uploaded the mfa in the 4shared: http://www.4shared.com/file/19141516...ion_Masks.html
The events with Collision Masks are in the group "Object Engine".
Hold the left mouse button to shoot an object.
The problem is: If you shoot more then one at frame, the collision works only in one (the last created)
Re: Collision Masks for every object?
Quote:
Originally Posted by Alves
Ok, I uploaded the mfa in the 4shared:
http://www.4shared.com/file/19141516...ion_Masks.html
The events with Collision Masks are in the group "Object Engine".
Hold the left mouse button to shoot an object.
The problem is: If you shoot more then one at frame, the collision works only in one (the last created)
I don't see what this has to do with collision masks! :P
The reason that your code isn't working, however, is because the expressions X("object") and Y("object") only get the most recently created selected object. You didn't select a specific object in your obstacle events, so it just uses the most recent one. You gotta use fastloops instead.
This seems like a bit of an advanced coding method for your level of experience. Might I suggest that you use MMF's built-in bouncing ball movement instead?
(object properties-->movement tab-->type-->bouncing ball)
Then, the only event you'd need is Collides with background-->bounce.
Re: Collision Masks for every object?
Quote:
The reason that your code isn't working, however, is because the expressions X("object") and Y("object") only get the most recently created selected object. You didn't select a specific object in your obstacle events, so it just uses the most recent one.
but even using a spread value system to select a specific object, or using the "Pick an object", the collision masks ALWAYS will do the events for the last object created, this is what I don't understand, I think that it maybe a bug in Collision Masks of MMF. :|
Quote:
This seems like a bit of an advanced coding method for your level of experience. Might I suggest that you use MMF's built-in bouncing ball movement instead?
(object properties-->movement tab-->type-->bouncing ball)
Then, the only event you'd need is Collides with background-->bounce.
I dont wanna use pre-defined MMF2 movement :/
I made this 360 degrees engine of bounce and I want to use it, a pre-defined bounce only have 32 directions, is too limited for my game style.
Re: Collision Masks for every object?
The MMF selection system is a complex system with unintuitive behaviors that I could probably write a book on.
However it doesn't look like you're being bit by the more obscure subtleties of selection. Spreading values should absolutely work here. There's several articles written on the subject if you need help with it.
Re: Collision Masks for every object?
I actually need help understanding 'spread value'
I literally have no idea how to use it and I think my current game now needs it.
Could someone maybe point me to a tutorial or something similar to help me with spread value?
Re: Collision Masks for every object?
Hi MonkeyPunch. I have an commented open source Spread Value Example on my website that may help.
Marv
Re: Collision Masks for every object?
Heya, thanks for that. There seem to be quite a few tuts there that might help me.
On the note of Spread Value - I'm still not understanding it completely... in fact I'm not even sure any more that it's what will help my problem.
The problem I have is that I have a gun in my game that uses a fastloop for a specific projectile.
When I shoot more than one projectile and the first hits a wall it disappears but so do any other airborne projectiles.
Should I be trying to solve this problem with Spread Value?
Re: Collision Masks for every object?
Quote:
Originally Posted by MonkeyPunch
The problem I have is that I have a gun in my game that uses a fastloop for a specific projectile.
When I shoot more than one projectile and the first hits a wall it disappears but so do any other airborne projectiles.
Should I be trying to solve this problem with Spread Value?
Hmm... Your problem sounds more like an issue with the order of events and conditions. We'd have to see an example to be sure.
For example, say you had a Bullet object with a Alterable Value named "Type" and use that to represent different projectiles (1=bullet, 2=missle, 3=laser, etc).
Normally, a "Collision" event in MMF triggers only for the specific objects that collide:
+ Bullet: Collisions with Backdrop
+ Type = 2
=> Create Explosion
=> Destroy Bullet
The above event should check for collided objects, then checks if they are "Missle Type," creates explosion, and destroys. Everything is perfect. Here is another example:
+ Type = 2
+ Bullet: Collisions with Backdrop
=> Create Explosion
=> Destroy Bullet
When ordered this way, it first checks for Missle Type. If the Type = 2, then the event will be considered "True." This will select ALL objects with Type 2. Now MMF moves on to the next line. It checks for collisions on all Bullets. If ONE bullet collides with Backdrop, the condition remains "True." But the first line already selected ALL bullets Type = 2.
What this means is that when the first bullet collides, MMF has already "selected" all bullets with Type = 2. Therefore, it will destroy all bullets with Type = 2. This is why we have to make sure Collision conditions are first in the event order. By putting collision conditions first, MMF selects only the objects that collide
This may help your situation.
Re: Collision Masks for every object?
Regarding object selection and collision masks, why not set an alterable value of the multiple-instance object to the collision mask? That way there's no need for loops and you just check if the alterable value is 0 or 1 for collisions.