Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Place block on the sides of another block

Author
Message
Ancores
12
Years of Service
User Offline
Joined: 13th Sep 2011
Location:
Posted: 20th Sep 2011 00:58 Edited at: 20th Sep 2011 01:04
Hello, I'm trying to figure out how I can place a block on another block in all directions.

If I have my crosshair on the right side of a block, I want another block placed next to it on the right side,
if I have my crosshair on the top of a block, I want another block placed on top of it etc.

What my code looks like now:


All this does is placing a block on top of another block, doesn't matter which side of the block I'm looking at.

I started with 3D programming today, so if you think my code looks bad it would be great if you could tell me how to improve it.
It might not be enough code to help me, but well, the main problem is the placing of blocks :p

If you don't understand or need any more info, just ask

Thanks.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 20th Sep 2011 05:25 Edited at: 20th Sep 2011 05:29
To place the block on any side, you need to detect which normal the crosshair is pointing at and place the block accordingly. I don't know how to do this with native DarkGDK, but Sparky's collision plugin has a raycasting and normal detection system, making this block placing function easy to make, and also adding good collision and gravity to your 3D world.

EDIT:
Here is a link to Sparky's Collision http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5
Ancores
12
Years of Service
User Offline
Joined: 13th Sep 2011
Location:
Posted: 20th Sep 2011 17:49
Could you give me an example?
I'm having a hard time with collisions, can't figure out how I should do it.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 21st Sep 2011 05:45 Edited at: 21st Sep 2011 05:45
This IF statement will "shoot" an invisible line and detect which side of the box you hit. "NormalX" "NormalY" and "NormalZ" are the sides of the box. For "NormalX" 1 is the left side, -1 is the right side, for "NormalY" 1 is the top of the box, and -1 is the bottom of the box, for "NormalZ" 1 is the front of the box, and -1 is the back.



Feel free to ask if you need more help setting up Sparky's, I know I had a very hard time when it came to collisions and physics.
Ancores
12
Years of Service
User Offline
Joined: 13th Sep 2011
Location:
Posted: 21st Sep 2011 15:08
Thanks alot!
Works perfect and that code really helped me understand how I can use Sparky's Collisions.

Login to post a reply

Server time is: 2024-05-04 09:29:32
Your offset time is: 2024-05-04 09:29:32