One of the biggest games I've made! yet...
One of the biggest games I've done! Over +3,000 blocks 🔥
Here's one of the hardest things I had to do:
Placing & Grabbing Objects
While grabbing objects was easy, placing was harder:
I had to create a plane over surfaces where you can place things, now, the hard part, was detecting if the player was looking at it and where exactly.
For that, I created a list containing the points of a raycast coming from the player:
(not actual language of the game, just to simplify)
x = Player.X y = Player.Y z = Player.Z repeat 300 times { x += sin(camera.Y.Rot)*0,5 z += cos(camera.Y.Rot)*0,5 y += sin(camera.X.Rot)*0,5 add vector3(x,y,z) to [Raycast] }
Now for collision it's a bit more complex, first I need to know the size of objects:
maxVector = search highest points of every dimension of the model minVector = search lowest points of every dimension of the model
Then search for a point in [Raycast] that is (distance from (0,0,0) to (maxVector)) to the object.
Ray in d range | No ray in d range | |
object | ![]() | ![]() |
plane | ![]() | ![]() |
That would be for detecting if looking at an object. What about placing?
Using the same list [Raycast], search if its near a plane (surfaces where the player can place objects, highlighted in game).
That would work, for detecting if its touching the plane. We want to know the exact point of collision!
If a point of the raycast is touching: clamp to x,y,z if x < min x = min else if x > max x = max else x = current (means that it's inside object in x) ...
then for the Y just detect if it's near to the plane Y (since it's just a plane with no volume).
If all of that is true, then save that point position and it'll be the placing site!
The Chores!
You have 5 minutes until mom arrives!
Status | Released |
Authors | Civero, Tricky |
Genre | Simulation |
Tags | 3D, Indie, Non violent, PSX (PlayStation), Singleplayer |
More posts
- Small Fixes40 minutes ago
- Bug Fixes!19 hours ago
Leave a comment
Log in with itch.io to leave a comment.