This will probably sound complicated, but I’ll try to keep it as short and straightforward as possible. (Thank you for taking the time to help me out )
Now that I think about it, it’s more of a heap than stacking. But I’m trying to do something like this:
So it starts off at the bottom and works its way up and it fits things on top of each other by rotating and positioning them. I know this would probably require a lot of math and I’m not even sure if this is possible. So this could end up being really interesting or really impossible…
Hopefully the first one.
If you need any more details please ask as I would appreciate any help given to me because I know this is no small task. I have already attempted to get this working myself but so far I’m not even close to it, I’ll keep trying though.
Do the items have a coded order, or can you just put anything inside the cart randomly? If its in a specified order, you can position the stuff inside it beforehand, make them invisible, and just keep making them visible.
If you can put random things in it, I don’t think its possible to make it look good. But I have an idea
So basically, I would split the cart in lets say 3 columns, and store each stuff in a different column. First the A then the B then the C, or even randomized.
If I want to place an object, I choose the column, then raycast down from the corresponding yellow spot (maybe just a stud above the cart), and put the object where it hits
+ Size.Y/2. And then maybe add a random rotation to it so it looks more natural.
You need to add
Size.Y/2 because the ray would hit the top of the object, which should be the bottom of the new object. And since a part’s position is exactly the center of the part, you have to go half its size up to place it on top of the previous part. I couldn’t explain this better but I really hope you understood
Im not sure if it would work, or if it would look good, but worth a try
Yeah, the player decides what goes in and what goes out the cart. I think your method is worth a try, the only thing is for different-sized items they’d have to shrink. But I’m going for a cartoony style anyway so I’ll see how it does.
Edit: I don’t have time to get started on it today but I was thinking about this and then realised there might be some obvious gaps between “A B and C” so I’ll just try to minimise it as much as possible.
I’d have to use local space instead of world space so it can work with rotation, but I’m not quite sure how to do that. I have a script and I can send it to you in pms if you’re able to help me?