I want to make sure that when these two cylinders grow in length, they won’t ever overlap.
This is all I have so far, but it doesn’t seem to work. Mind you I’m not very good at CFrame.
RedCylinder.CFrame = GreenCylinder.CFrame * CFrame.new(0, (GreenCylinder.Size.Y / 2 - (GreenCylinder.Size.Y * self.YSpawn)), 0)
-- Gets where the red cylinder should spawn, not accurate to the image above sorry.
RedCylinder.CFrame = CFrame.lookAt(RedCylinder.Position, GreenCylinder.Position - Vector3.new(math.random(-360, 360),math.random(-360, 360),math.random(-360, 360)))
-- Makes the RedCylinder look away from the GreenCylinder and adds random orientation, doesn't work 100% of the time however.
Just trying to make the RedCylinder be able to greow in the same general direction (in this case upwards) but also not ever intersect with the GreenCylinder. Or any other RedCylinders in the future that might be added?
Any help is appreciated. My current method is just to have the RedCylinder look away from the GreenCylinder and add random orientation, however it doesn’t always work.
Not sure how to ask this question, but how can I make the orientation/math you sent be relative to its current orientation?
Both green and red cylinders can generate on any surface normals. So the math you sent does work for cylinders that generate on the ceiling, however ones that generate on the walls or floor become inverted.
Imagining if the red line was a floor that the cylinders shouldn’t grow into, how can I always have the cylinders generate facing up from it?
I use :Raycast() to actually get the cylinder spawning positions, do I need to use RaycastResult.Normal for this?