• Advertisement
Sign in to follow this  

Build 3D objects in-game?

This topic is 1003 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to know if this techique has a name and how it works:
 
 
I saw it in several games, where object are automatically aligned near other objects to build a house or whatever.
 
 
 
can anynone help me?

Share this post


Link to post
Share on other sites
Advertisement

I don't know if it has a name, but it looks like the game is determining possible locations for whatever item type is selected and then just casting a ray from the cursor and highlighting the indicated position.

Share this post


Link to post
Share on other sites

It looks to me that the world in this game is built of an invisible cube-based grid.

 

When you click the mouse cursor, a ray is projected from the current view plane until it hits the first cube plane of the grid, and where it hits, it projects the 'ghost' box to hint at where it might place the item.

 

Each item has a weight and mass and is a physics object, in this case in UE4 it would be PhysX. These physics objects can be placed and have enough mass to support each other and the player. I'm guessing here, but i'd do this and not use kinematic objects to allow the player to later destroy their construction using weapons or by dropping things onto it (think like angry birds).

 

Something like this would probably take an hour or so to make in UE4, probably a bit longer if you werent using a pre-made engine.

Share this post


Link to post
Share on other sites

well i'm working with ue4, but don't really know where to start.

also searched about alignment and snapping, but haven't found much 

Edited by Sleicreider

Share this post


Link to post
Share on other sites

What have you tried?

 

 

Can you perform the first thing shown in that video, looking at a spot and dynamically spawning some object where you're looking with a keypress? If not, consider focusing only on that problem first.

Share this post


Link to post
Share on other sites


Can you perform the first thing shown in that video, looking at a spot and dynamically spawning some object where you're looking with a keypress? If not, consider focusing only on that problem first.

 


yup i know how to do that

 

so you take the x,z position you'd place the object at, integer divide x and z by 10, then multiply x and z by 10, and just like that you're snapping to 10x10 grids.

 

IE: raypick returns coordinates 127,38.  integer divide by 10 yields 12,3. multiply by 10 yields 120,30. so you picked 127,38, but snap to 120,30.  

 

then its just setting the orientation (y rotation). axis aligning everything is one easy way to handle this.   IE y rotation = 0, and make sure your models face the correct direction in your modeling software before export.

 

that's the general approach that first comes to mind.

Share this post


Link to post
Share on other sites

 


Can you perform the first thing shown in that video, looking at a spot and dynamically spawning some object where you're looking with a keypress? If not, consider focusing only on that problem first.

 

 

 


yup i know how to do that

 

so you take the x,z position you'd place the object at, integer divide x and z by 10, then multiply x and z by 10, and just like that you're snapping to 10x10 grids.

 

IE: raypick returns coordinates 127,38.  integer divide by 10 yields 12,3. multiply by 10 yields 120,30. so you picked 127,38, but snap to 120,30.  

 

then its just setting the orientation (y rotation). axis aligning everything is one easy way to handle this.   IE y rotation = 0, and make sure your models face the correct direction in your modeling software before export.

 

that's the general approach that first comes to mind.

 

 

this seems to be a good solution :)  i'll try it as fast as possible 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement