Pushing furniture around

Blitz3D Forums/Blitz3D Programming/Pushing furniture around

MadMax(Posted 2003) [#1]
Any ideas on how to push objects around?


jhocking(Posted 2003) [#2]
You should be more specific in asking your question. First off describe the objects being pushed (you said "furniture" but that is still pretty vague) and the objects doing the pushing. The setting would help too (in particular, the surface on which the objects are being pushed.)


(tu) sinu(Posted 2003) [#3]
if the player and furniture object are clolliding, translate the entity in the x/z directions based on the collision normals and players movement speed.


yinch(Posted 2003) [#4]
Also decide if you want your furniture to rotate when pushed - it adds a degree of realism but also complexity to the simulation.

You'll have to consider how 'off-centre' an impluse has to be to make the furniture turn instead of slide.

Consider if the furniture ever leaves the floor - e.g. lifted or else pushed off the edge of a platform.

Having said that - non-rotating pushable furniture is a perfectly usable solution (see Half-Life 1 et al) which does add something to an environment.

y'03


MadMax(Posted 2003) [#5]
OK, I'll try to be more specific, I think yinch get's the idea of what I want to do very well, let's say for a start I'm happy to stick with the "non-rotating-pushable" option. What I realy need is something to get me started, there seem to be some commands in B3d, but to the contrary to the 2D ones; those dealing with 3D (not all but many) don't seem to explain much, and don't come with a sample to play around with. And the truth is I'm not sure how I would go about making the collided object moving in the direction of the colliding object if and only if it's blocking it's advance ( thought about getting it to move with the colliding object, but then it would not only push, it would pull as well (Superglue?) I could (suposition) work out a complex way to do this, but I'd hate to find out, that the same could be archieved, with the clever use of a few commands. :)

Thanks in advance.


jhocking(Posted 2003) [#6]
I would want you to be more specific (eg. describe the game; is it first-person?) but I think sinu has already mentioned the most important thing for you to know. You want to check the collision normal. That will tell you the direction of the collision (ie. which direction the collided object is being pushed.)


sswift(Posted 2003) [#7]
Look at the ball rolling code I posted a couple forums up. If you take out the part about rolling, and subsitutue a chair for the ball, and subsitute the amount of force the player is applying to the object for the force the player applies with the arrow keys to the ball, then you'll have a pushable object simulator.

When I say subsitute the amount of force the player applies to the object, I mean detect that a collision has occured, and then take the player's velocity vector, the speed/direction they are moving on each axis of the world, and then add that, to the velocity of the object. You can also make the object harder to push by say, dividing the force in half, and having the chair push back on the player with an equal amount of force so they move more slowly when they are pushing against it and it is pushed more slowly.


DarkEagle(Posted 2003) [#8]
Function ControlP1()

xinc# = (KeyDown(205) - KeyDown(203)) * 0.1
zinc# = (KeyDown(200) - KeyDown(208)) * 0.1

p1\xvel# = (p1\xvel# + xinc#) * 0.7
p1\zvel# = (p1\zvel# + zinc#) * 0.7

TranslateEntity p1\entity,p1\xvel#,p1\yvel#,p1\zvel#

For i = 1 To CountCollisions(p1\entity)
	For b.box = Each box
		If CollisionEntity(p1\entity,i) = b\entity
			b\xvel# = p1\xvel# * Abs(CollisionNX(p1\entity,i))
			b\zvel# = p1\zvel# * Abs(CollisionNZ(p1\entity,i))
		End If
	Next
Next

End Function


Function UpdateBoxes()

For b.box = Each box

	TranslateEntity b\entity,b\xvel#,b\yvel#,b\zvel#

	x# = EntityX(b\entity)
	y# = EntityY(b\entity)
	z# = EntityZ(b\entity)
	
	b\xvel# = x - b\px
	b\yvel# = y - b\py
	b\zvel# = z - b\pz

	b\xvel# = (b\xvel#) * 0.7
	b\yvel# = (b\yvel# - 0.1) * 0.5
	b\zvel# = (b\zvel#) * 0.7
	
	b\px# = EntityX(b\entity)
	b\py# = EntityY(b\entity)
	b\pz# = EntityZ(b\entity)
	
Next

End Function


taken from my little fun project :P


MadMax(Posted 2003) [#9]
cheers, i'll try out these things.


IPete2(Posted 2003) [#10]
MadMax,

The other quick and dirty way would be:-

(1) Check for collision between player and furniture
(2) Parent collided object to player (make player look like they have a hold on the furniture)
(3) Moving player now move furniture
(4) Have a special key to drop the furniture
i.e. release the parenting of the object to the player.

(Oh if you are meaning a first person mover then the camera would be the player I guess.)

This means player could carry stuff up and down stairs, into new rooms etc. with very little coding.

regards,

IPete2.