Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

How to use altercollision tiles

Share questions and tutorials related to the map editor. Share you maps in the Superfighters Deluxe Custom Maps section.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
gwendalaze
Superfighter
Superfighter
Posts: 84
Joined: Sat Mar 19, 2016 12:55 pm
Title: Jarate Yellow Belt
Started SFD: PreAlpha 1.1.4
Location: France

How to use altercollision tiles

Post by gwendalaze » Thu Aug 25, 2016 5:39 pm

Some people asked for help on discord, so here I go.

I'm going to speak about maskbytes, categorybytes and abovebytes. The disable collision between objects thing and disabling melee hits and shot collision is really straightforward anyway.

Those will allow you to change the behavior of tiles : You can disable collisions between a player and a crate for example.

HOW :

1) Learn how hexadecimal works

to make it simple, Hexadecimal is a way to translate easily long binary numbers into short numbers.
Digits in hexadecimal range from 0 to F, as digits in decimal (normal numbers) range from 0 to 9.
Digits in binary range from 0 to 1 and are called bytes.

Those digits, and their translation in binary are :

0000 : 0 | 1000 : 8
0001 : 1 | 1001 : 9
0010 : 2 | 1010 : A
0011 : 3 | 1011 : B
0100 : 4 | 1100 : C
0101 : 5 | 1101 : D
0110 : 6 | 1110 : E
0111 : 7 | 1111 : F

Altercollisiontiles use four-digit hexadecimal numbers, ranging from 0000 to FFFF

2) Check the binaries

go to C:\Program Files (x86)\Superfighters Deluxe\Content\Data\Tiles\collisionGroups
open the .sfdx in your notepad

Those are the binary values for the maskbytes, categorybytes and abovebytes of different items.
In our example, we want to disable the collision between players and a crate.

Take note of the maskbytes and categorybytes of the player and of the crates

3) Disable the collision

When do collide two different objects ?
they collide when one byte in the categorybyte of the first object is to 1 while the same byte of the maskbytes of the second object is to 1.
Note that it apply reversally, with categorybytes from the second object and maskbytes from the first object

for coders out there, the method is bool collision = (filterA.maskBits & filterB.categoryBits) != 0 &&(filterA.categoryBits & filterB.maskBits) != 0;

So, what do we do ?
First, check the categorybytes of the crate(dynamic_g1) :
0000 0000 0000 1000
as you can see, the fourth byte (starting from right) is 1; meaning that if the player's fourth maskbyte is at 1 too, then there will be a collision.

The player's maskbytes are :
0000 0000 0000 1011
the player's fourth maskbyte equals 1, that mean that players collide with crates.

As you may have noticed, altercollisiontiles disable category and mask bytes
so, if we want to make so that the crate can't hit players, we will have to either
- disable players fourth maskbyte
- disable crate's fourth categorybyte

It's easier to handle the crate, then we will go for the second solution

link your atlercollisiontile to the crate, and disable the bytes you want to disable.
for instance, you want to disable the fourth byte of the crate's categorybytes
that translate to 0000 0000 0000 1000 in binary

But, since altercollisiontiles use hexadecimal rather than binary, you have to translate the binary number into a hexadecimal one :
0000 0000 0000 1000 in binary = 0008 in hexadecimal,
since 0000 : 0 and 1000 : 8

Now write 0008 into the 'disable categorybytes' section of the altercollision tile

However, your crate still collide wih players.
Why ?

check the categorybytes of players :
0000 0000 0000 0100
and maskbytes of crates(dynamic_g1) :
1111 1111 1110 1111

can you see it ?
Third bytes on both number are set to 1.
Thus, we want to set to 0 the third (and only the third) byte on the crate's maskbytes :
0000 0000 0000 0100
that translate in hex to 0006
now, put it in the 'disable maskbytes' section

et voilà ! You cannot collide with the crate anymore !

4) Summarizing

You will have to do these few steps to disable the collision between two objects :
  • Check and take note of the categorybytes and maskbytes of both object
  • Find the conflicting bytes in first object's categorybytes and second object's maskbytes
  • Disable the category byte(s) of the object that is easier to manipulate according to the previous step
  • Repeat : Disable the maskbyte(s) of the same object, depending of conflicting bytes between first object's maskbytes and second objectt's category bytes
  • gg ez
5) Bonus

Here are some tips :
  • In the .sfdx file, there are listed the position of the category bytes of the different type of objects;
  • If you are too lazy to check, and only manipulate objects from the same type, you can just write FFFF in the disable categorybyte section
  • Abovebytes act the same way as maskbytes, but they only come in action when an object land ON THE TOP of another one. That allows small objects and debris to pass under covers such as crates and barrels.
  • You can only disable collisions, not enable them. Think about it before trying something.
7 x
- Gwendalaze, failing at being fun, just like this signature

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Fri Aug 26, 2016 7:39 am

Wow Gwen, thank you! This is very helpful!
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Fri Aug 26, 2016 8:52 pm

For info:
No support today to enable bits. You can only disable them. Might be some future thing to complement the disableAlterCollisionTile.
2 x
Gurt

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Tue Apr 24, 2018 6:55 pm

Bumping into an old thread, but having an important question: How do we know which layers are the objects on? If we make a static tile dynamic is it in dynamics_g1 or dynamics_g2 or like is it still in static_ground?
1 x
Image

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Mon Apr 01, 2019 8:05 pm

I'm still waiting for an answer @Gurt
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Mon Apr 01, 2019 8:26 pm

You can not manipulate/change which layer an object is located in. The layer only defines the rendering Z-order of tiles. The collision has nothing to do with the layers.
The dynamics_g1, dynamics_g2 and static_ground you refer to is just predefined collision groups with a name (which can be found in some other file somewhere in the SFD content folder).

In v.1.1.2 and forward you can ENABLE and DISABLE collision using the ScriptAPI with the GetCollisionFilter() and SetCollisionFilter(..) functions.
Something like:

CollisionFilter filter = obj.GetCollisionFilter();
filter.MaskBits = 0x0000; // disable stuff
filter.CategoryBits = 0xFFFF; // enable stuff
obj.SetCollisionFilter(filter);

It's for those that know a how the box2D engine collision filters work.
2 x
Gurt

User avatar
Kawabanga
Superfighter
Superfighter
Posts: 69
Joined: Sat Mar 19, 2016 10:36 pm
Title: Epic fails amateur.
SFD Alias: My name is Kawa-bbanggza!!
Started SFD: Late 2015
Location: Poland
Gender:

Post by Kawabanga » Mon Mar 22, 2021 9:31 am

gwendalaze wrote:
Thu Aug 25, 2016 5:39 pm

2) Check the binaries

go to C:\Program Files (x86)\Superfighters Deluxe\Content\Data\Tiles\collisionGroups
open the .sfdx in your notepad
I think there is no "Tiles" folder anymore. Can't find collisionGroups. Specificaly, for a No Collision Invincible Block, I want to enable bullet and explosion collision. Which collision group(s) should I refer to in a script?
0 x

User avatar
Odex64
Superfighter
Superfighter
Posts: 172
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Mon Mar 22, 2021 6:01 pm

Kawabanga wrote:
Mon Mar 22, 2021 9:31 am
gwendalaze wrote:
Thu Aug 25, 2016 5:39 pm

2) Check the binaries

go to C:\Program Files (x86)\Superfighters Deluxe\Content\Data\Tiles\collisionGroups
open the .sfdx in your notepad
I think there is no "Tiles" folder anymore. Can't find collisionGroups. Specificaly, for a No Collision Invincible Block, I want to enable bullet and explosion collision. Which collision group(s) should I refer to in a script?
The path is correct... it's inside the steam folder after the release. Anyways if you want to enable bullets and explosions you don't even need to deal with bits.. just use this line of code:

Code: Select all

Game.GetSingleObjectByCustomId("CollisionBlock").SetCollisionFilter(new CollisionFilter { AbsorbProjectile = true, ProjectileHit = true, BlockExplosions = true });
Your invisible block must have CollisionBlock as custom id.
0 x
Image

User avatar
Kawabanga
Superfighter
Superfighter
Posts: 69
Joined: Sat Mar 19, 2016 10:36 pm
Title: Epic fails amateur.
SFD Alias: My name is Kawa-bbanggza!!
Started SFD: Late 2015
Location: Poland
Gender:

Post by Kawabanga » Tue Mar 23, 2021 9:59 pm

The above script does not seem to work stand-alone. It causes error.
0 x

User avatar
Odex64
Superfighter
Superfighter
Posts: 172
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Wed Mar 24, 2021 11:29 am

Kawabanga wrote:
Tue Mar 23, 2021 9:59 pm
The above script does not seem to work stand-alone. It causes error.
Because you have to put it inside a method.

Code: Select all

public void Triggered(TriggerArgs args)
{
    Game.GetSingleObjectByCustomId("CollisionBlock").SetCollisionFilter(new CollisionFilter { AbsorbProjectile = true, ProjectileHit = true, BlockExplosions = true });
}
Then use any trigger to call this method.
0 x
Image

Post Reply