I am working on a script and I really need a fast way to tell if an object can collide with other object.
this method Game.GetObjectsByArea() returns all kinds of unnecessary tiles even far-background object.
I could make a string list of all the 809 Bg Tiles and 101 FarBG tiles but it's gonna take a lot of time..
hint : It is possible to get the name of IObject as a string . If it is a Background object it will begin with the prefix "Bg" , such as :"BgLamp00A" . Getting the initials of a string might be the key to the problem.
big thanks in advance !
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.
New to the forum? Say hello in this topic! Also make sure to read the rules.
How to tell if an Object is a background object ?
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
- gwendalaze
- Superfighter
- Posts: 84
- Joined: Sat Mar 19, 2016 12:55 pm
- Title: Jarate Yellow Belt
- Started SFD: PreAlpha 1.1.4
- Location: France
area triggers don't detect background and far background tiles
that may help you
that may help you
0 x
- Gwendalaze, failing at being fun, just like this signature
- Motto73
- 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
As Gwen says, the area triggers are ok, but I think that they dont recognize static tiles. You could maybe use something like this:nerdist wrote:I am working on a script and I really need a fast way to tell if an object can collide with other object.
this method Game.GetObjectsByArea() returns all kinds of unnecessary tiles even far-background object.
I could make a string list of all the 809 Bg Tiles and 101 FarBG tiles but it's gonna take a lot of time..
hint : It is possible to get the name of IObject as a string . If it is a Background object it will begin with the prefix "Bg" , such as :"BgLamp00A" . Getting the initials of a string might be the key to the problem.
big thanks in advance !
Code: Select all
Area SomeArea=new Area(0,0,0,0);
public void Check(TriggerArgs args){
IObject[] objs = Game.GetObjectsByArea (SomeArea);
List <IObject> TheObjects = new List<IObject> ();
foreach(IObject obj in objs)
if (!obj.Name.StartsWith ("Bg") && !obj.Name.StartsWith ("FarBg"))
TheObjects.Add (obj);
//Do something with the tiles
TheObjects.Clear();
}
1 x
- Gurt
- Lead Programmer
- Posts: 1884
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
For info:
"How to tell if an Object is a background object ?" We lack that feature in the ScriptAPI today. Meta data like this will most likely be available in later versions of the game.
You probably want something like obj.Name.ToUpper().StartsWith ("BG" / "FARBG") or similar today.
"How to tell if an Object is a background object ?" We lack that feature in the ScriptAPI today. Meta data like this will most likely be available in later versions of the game.
You probably want something like obj.Name.ToUpper().StartsWith ("BG" / "FARBG") or similar today.
2 x
Gurt