I’m trying to make my entites fall down to the ground, but not fall through the map. This is what I got currently
function EntityControl:Create(entityType, amount, position)
for i = 1, amount do
local Entity = Instance.new('Part')
Entity.Color = EntityData[entityType].Color
Entity.Material = Enum.Material.SmoothPlastic
Entity.Name = entityType
Entity.Position = position
Entity.Anchored = true
Entity.CanCollide = false
Entity.Size = Vector3.new(1, 1, 1)
Entity.Parent = Entites
Debris:AddItem(Entity, 5)
local NewPosition = Entity.Position + Vector3.new(0, 0.75, 0)
local Tween = TweenService:Create(Entity, Info, {Position = NewPosition})
Tween:Play()
spawn(function()
while wait() do
Entity.Orientation = Vector3.new(0, Entity.Orientation.Y + 2, 0)
end
end)
end
end
Which does this
So they kinda just stay mid air.
I’ve tried setting Anchored to false, CanCollide to true, but they glitch out with the tweening and what not. I thought about maybe just making them spawn on the ground, but if I let them fall naturally they should spread out right? In the gif you can only see 1 item, but there’s actually 3, they are just all grouped together, which I don’t want, I want all 3 to kinda fall to the ground, be a little spread out, and just bob on the ground
You can make it so when you destroy the tree, the entity falls, and when it touches the ground, it starts playing the animation(then you would set the anchored to true)
No, what I mean is that you make the can collide to true and the anchored to false, and when it hits the ground, it wont go through because the can collide is true. So, when it touches the ground, you tween it up a bit, and start playing the animation(with the anchored set to true after it touches the ground)
You could ray cast down and see how far it is until the floor. Then do an animation down to the floor and then a floating animation - that should work.
local RayToGround = Ray.new(Entity.Position, Vector3.new(0, -1 * 100, 0))
local PartFound, Pos = workspace:FindPartOnRay(RayToGround)
print(PartFound, Pos)
My raycast seems to get my rays that are created from a hitbox module RaycastHitboxDebugPart 25.5, 2.21859074, -33 (x3)
(using a module that creates rays on melee items for good hitboxes)
What is this position? If it is the position of the tree trunk, then you would be able to set the position to: Vector3.new(0, (position.x - TreeTrunk.Size.x / 2) + 0.5, 0)
Why do you need the part without collisions, is it so that its unable to collide with players and such? The only way I can fathom you fixing this is to use collision groups to filter collisions. That means to create a few groups for different parts of your game and make said blocks not collide with them.
Well another reason I don’t really wanna just set the Anchored to false and let it fall naturally is because when parts hit the floor, they can bounce around, flip onto their sides etc. I want the part to fall down, with a little bit of a curve to each one, so they spread out, and hit the ground facing up