Code archives/Algorithms/Pushing Objects
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Basically i came up with this idea after playing unreal! it works!!! this is a snippet from my game but its so easy i thought id share it, Its very basic so there are some things i haven | |||||
(I let this code free) [codebox] If lpEnvpushable=True ;translateentity lpEnvmodel,0,-.1,0 z = EntityCollided(ThisActor, coll_objects) If z = lpEnvmodel i=1 ; Calculate bounce: ; Get the normal of the surface which the entity collided with. Nx# = CollisionNX(ThisActor%, i) Ny# = CollisionNY(ThisActor%, i) Nz# = CollisionNZ(ThisActor%, i) vy# = VectorYaw(-nx, -ny, -nz) tfm_z# = Cos(vy#)/5 tfm_x# = -Sin(vy#)/5 tfm_y# = VectorPitch(-nx, -ny, -nz) If Abs(tfm_y)<60 Then TranslateEntity lpEnvmodel,tfm_x,0,tfm_z End If End If [/codebox] |
Comments
| ||
I dont have B3D, so I havnt tested it out but I think this function would be great if someone could translate it to 2D!? |
Code Archives Forum