Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Force CanCollide False on Rig / Dummy Humanoids (Not Player)?

Asked by
x_Tso 48
5 years ago
Edited 5 years ago

So, for some strange reason, humanoids (whether in the player (I believe) or in a rig) do not like when you try to set 3 objects to CanCollide false: UpperTorso, LowerTorso, and Head. Why? I really don't know.

The issue arises in a game I'm working on, where I try to set an enemy to both be invisible and intangible for a cooldown period, so when the player respawns in the overworld after beating the enemy on the battlefield, they don't flop right back into the battle. Intangibility is also important, because, if the player were to abuse the hitbox this invisible enemy had while on cooldown, they could potential cause some out of bound glitches. Making the enemy invisible works fine. Making all but the 3 previously mentioned body parts of the rig CanCollide false also works incredibly okay. I just need to know what witchcraft needs to be done to make the Upper/LowerTorso and Head CanCollide false.

I started off by using a for in pairs command that scanned through all of the children of the rig and set everything to invisible and CanCollide false. When I found I still collided with this invisible dummy, I checked what wasn't set to CanCollide false. When I found the 3 parts, I tried to manually set them to CanCollide false from that point to see if that was the issue. And when I clicked CanCollide, and set it to false, you know what I see? The game flips it right back to true. In less than a half second. Probably less time than the wait() time at the lowest increment. So I can just use a while wait() do loop to constantly set it back to CanCollide true. I mean, I wouldn't want to anyways. To have a loop run endlessly during that cooldown period might cause some slight slowdown. In my previous games, using an infinite amount of while wait() do loops caused endless amounts of throttle requests. I don't want that again, as it might cause performance issues.

Even still, I tried manipulating a RunService.Step (I believe that's it's name) to set it CanCollide false at every possible frame. Still didn't work somehow (the CanCollide checkbox was constantly checked at true without any blinking between false or true.) Of course, that's not the method I want to take, but if it's the only solution, I might have to try it.

My idea is to use CollisionGroups, which would require me actually learning what a CollisionGroup is in the first place. I have a script that makes it so players can't collide with each other, and I'm thinking that the easiest solution would be to just set the rig to that very same CollisionGroup during the cooldown time. No loops running infinitely, no throttles, just a quick clean change. Problem is, I have no idea how to set a CollisionGroup to a group defined in another script. Here's what I'm talking about:

--script one
local playerCollisionGroupName = "Players"
PhysicsService:CreateCollisionGroup(playerCollisionGroupName)
PhysicsService:CollisionGroupSetCollidable(playerCollisionGroupName, playerCollisionGroupName, false)

And then:

--script two (different script than the first one that defined collision group "Players")
--??

Another issue, I need to set this all in a LocalScript, so it functions on the client side. The enemy only becomes intangible for the one player who just battled it, not the entire server. It doesn't seem I can set CollisionGroups via a local script, so I'm running low on ideas. Any help?

1 answer

Log in to vote
0
Answered by
x_Tso 48
5 years ago

every time I ask a question I figure it out myself within 2 minutes.

CollisionGroupId (a property of BasePart).

to find the id of a CollisionGroup defined in another script, just do this:

local id = PhysicsService:GetCollisionGroupId("CollisionGroup String Name")
print(id) 

then set whatever number prints to the CollisionGroupId property. it was that easy I am so sorry guys

Ad

Answer this question