Gamasutra: The Art & Business of Making Gamesspacer
Games Demystified: Super Mario Galaxy
View All     RSS
February 21, 2018
arrowPress Releases
February 21, 2018
Games Press
View All     RSS






If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

Games Demystified: Super Mario Galaxy


March 27, 2008 Article Start Previous Page 3 of 4 Next
 

The component we'll be focusing on is the updatePhysics() function - here's a code sample from that section:

;====== UPDATE PHYSICS =======================================

Function updatePhysics()

player.playerClass = Object.playerClass( localPlayer )

planetoid.planetoidClass = Object.planetoidClass( player\planetoid )

LinePick( EntityX( player\character ), EntityY( player\character ), EntityZ( player\character ), EntityX( planetoid\mesh ) - EntityX( player\character ), EntityY( planetoid\mesh ) - EntityY( player\character ), EntityZ( planetoid\mesh ) - EntityZ( player\character ) )

AlignToVector( player\character, PickedNX(), PickedNY(), PickedNZ(), 2, 1 )

player\nX# = PickedNX()

player\nY# = PickedNY()

player\nZ# = PickedNZ()

If (EntityCollided( player\character, STATIC ) )

player\jumpTimer = MilliSecs()

player\vX# = 0

player\vY# = 0

player\vZ# = 0

Else

player\vX# = player\vX# - PickedNX()

player\vY# = player\vY# - PickedNY()

player\vZ# = player\vZ# - PickedNZ()

TranslateEntity( player\character, player\vX#, player\vY#, player\vZ# )

EndIf

distance = EntityDistance( player\character, planetoid \mesh )

For planetoid.planetoidClass = Each planetoidClass

If ( EntityDistance( player\character, planetoid\mesh ) < distance ) Then player\planetoid = Handle( planetoid )

Next

End Function

;=============================================================

The first two lines in this function retrieve our player and the planetoid he inhabits. This sets us up to apply the calculations, which will allow gravity to occur between them. Next we cast a ray from our character's local center to the planetoids local center.

This call requires 6 parameters. The first 3 are the starting point of the ray and the last 3 are the distance along the (x, y, z) axes to cast our ray. We don't use the ray itself to calculate gravity. Instead we only use the ray to find a polygon between the player and the planetoid and extract its surface normal.



The first thing we do with the surface normal is character alignment. The call to AlignToVector() has 6 parameters; the object to be aligned, the vector to align to, the axis to align along, and the speed at which we interpolate or snap to this alignment.


Article Start Previous Page 3 of 4 Next

Related Jobs

Bohemia Interactive Simulations
Bohemia Interactive Simulations — ORLANDO, Florida, United States
[02.21.18]

Senior Software Engineer
Bohemia Interactive Simulations
Bohemia Interactive Simulations — Orlando, Florida, United States
[02.21.18]

Mid Software Engineer
Creative Assembly
Creative Assembly — Horsham, England, United Kingdom
[02.21.18]

Senior Infrastructure Programmer
Creative Assembly
Creative Assembly — Horsham, England, United Kingdom
[02.21.18]

Senior Gameplay and AI Programmer





Loading Comments

loader image