Box Collisions and Grabbing system?

For questions about using Classic.

Post » Tue Feb 05, 2008 8:46 am

I have a 3D box which can be spawned by the player and when I have 2 boxes and spawn them right after another or near each other they spawn inside each other. How can I make it push it out a bit so they aren't colliding??

I also want to be able to pick things up with the mouse. How can I do this. I have a system that sets the force towards the mouse when clicked and over the object. This however is buggy, since if I move fast it drops.

Thanks in advance.
B
1
G
4
Posts: 2
Reputation: 1,029

Post » Tue Feb 05, 2008 9:03 am

For the overlapping:

The first method to fix overlapping is to not spawn a box if the place it's spawning in is already occupied with a box. You could use an invisible detector object to check for it, so if the detector blips in and finds that there's already a box there, it'll just not spawn another.

The second way to do it would be to pick one of the overlapped boxes and use a loop to move it 1 pixel away until it's no longer overlapping. You could try something like this:

[code:9brjfm87]
+While
+spriteBox overlaps spriteBox
-Set spriteBox.X to (spriteBox.X-1)
[/code:9brjfm87]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Feb 05, 2008 9:09 am

The 3Dbox doesn't have the overlapping option.
B
1
G
4
Posts: 2
Reputation: 1,029

Post » Tue Feb 05, 2008 10:32 am

Ah, you know what? I totally missed the 3D part. Just skimmed right over it. Forget I said anything.

The short story: The 3D Box doesn't have collision detection, at least not the kind you're probably thinking of. Don't use the 3D box as a game object. It's for display only.

The long story: Okay, fine. You can use it as a game object, as long as you're clever about it. But I don't feel like typing the long story out (again). I've written up the 3D Box description a zillion times already.

Oh what the hell, I'll dig up a link for you...

Okay, here you go:
http://scirra.com/phpBB2/viewtopic.php?p=1406#1406

Anyway, if you want to do collision stuff with the 3D box, use a regular, invisible sprite as your collider. Perform all your game actions on the sprite instead of the box. Then just put in a "Always: 3DBox: Set position to object colliderSprite (image point 0)." Voil. It looks just like you're manipulating a 3D Box directly, and nobody's the wiser.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests