So I have a skill I made for testing that spikes a player from random angles and tweens the spikes cframe on the y axis and weld the player to middle to top of the spike, the probelm is or not so much a probelm but something I’m curious on how I would fix is that the spike that has the player welded to it scales through other parts like into the ground etc meaning that the welded player gets put into a wall or the ground.
Is there a way to make the part stop scaling when the space of where it is, is too small without having to set up a complicated system with collision groups and a touched event or something?
Thankyou for the help if you know anything on this topic.
Edit: Was thinking of using raycasing out of the top of the part but not sure if that’s the best way or theres a built-in roblox feature that can just stop a part from scaling when it collides with the floor or map or something.
Raycasting sounds like the best option to me. Like you said, just cast a ray out of the top of the part before every increment in the spikes Y size component. If it hits something, stop the growth, otherwise keep going until some end condition.
For anyone in the future, do basically what he said and what i was thinking, just raycast ouf the upvector of the part and then instead of stopping the growth just raycast before you grow the part or change the size or tween it or whatever then set the parts size lower than the (part.Position - RaycastResult.Position) then set the size to that or that and a little lower.
Yes, I thought of just casting a ray out the UpVector for the max distance you would like to extend the part as well, I was just thinking that in case something else in the world changed during the period when the part was growing, you may want to check the raycast after every increment. (But likely you would not need this level of specificity)