Teams
5 posts • Page 1 of 1
Teams
Im making a thing where 20 different teams go up against each other. There are 6 on each team and i want it if 1 team object bumps into another team object it kills. How do i make it so teams dont kill themselves or any block?
- YouCanNotKnow
- Posts: 3
- Joined: Wed Apr 05, 2017 3:45 pm
Re: Teams
So there are 20 teams (lets say each team has 5 different characters) in a box and they are battling. I want it so a team (lets say red team) can kill ANY other team (blue yellow green etc) but cant kill there own team. How do i do this?
- YouCanNotKnow
- Posts: 3
- Joined: Wed Apr 05, 2017 3:45 pm
Re: Teams
Here is a simple method to differentiate the teams:
In algodoo, every geometry has a "materialName" variable. I often use it as a universal identifier to check if something is of the correct type. So in order for your teams to work, name the materialName of every member the name of the corresponding team, for example "red, blue, yellow" etc. Then, all you need to do is go to onCollide to code events during collision, and check if the collision partner is NOT part of the own team, i.e. :
e.other.materialName != materialName && e.other.materialName != "" ? {e.other.timetolive = 0} : {}
By doing this, the collision of 2 objects with the same materialName, in other words the same team, will do nothing, just like the collision with something that's not part of a team. However, should 2 different team members collide, they will kill each other. You can modify the code in the first bracket to your liking, if instantaneous killing is not of your liking.
In algodoo, every geometry has a "materialName" variable. I often use it as a universal identifier to check if something is of the correct type. So in order for your teams to work, name the materialName of every member the name of the corresponding team, for example "red, blue, yellow" etc. Then, all you need to do is go to onCollide to code events during collision, and check if the collision partner is NOT part of the own team, i.e. :
e.other.materialName != materialName && e.other.materialName != "" ? {e.other.timetolive = 0} : {}
By doing this, the collision of 2 objects with the same materialName, in other words the same team, will do nothing, just like the collision with something that's not part of a team. However, should 2 different team members collide, they will kill each other. You can modify the code in the first bracket to your liking, if instantaneous killing is not of your liking.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest