Game Development Reference

In-Depth Information

^kqj_aT9,7

^kqj_aU9,7

bne_pekjT9,7

bne_pekjU9,7

y

++=llhulh]pbknibne_pekj

lh]uan*rt'9kt)bne_pekjT7

lh]uan*ru'9ku)bne_pekjU7

++Ikrapdalh]uankqpkbpda_khheoekj

lh]uan*t'9kt7

lh]uan*u'9ku7

++>kqj_apdalh]uankbbpdalh]pbkni

lh]uan*^kqj_aT9^kqj_aT7

lh]uan*^kqj_aU9^kqj_aU7

y

y

y

Platform bounce and friction

Although finding out on which side of the lh]pbkni a collision is occurring is reasonably straightfor-

ward, applying the right physics is a little a bit more complex. You need to find out in what direction

the object is traveling so that it can bounce away at the correct angle.

Lucky for you, you can borrow some formulas used in a branch of mathematics called
vector math

to help you sort this out.

To apply the correct bounce and friction when the lh]uan hits the platforms, you need to know three

things:

The direction the lh]uan is traveling in. You can figure this out by using a vector math formula

that calculates a value known as a
dot product
:

r]n`ena_pekjKb?khheoekj6Jqi^an9lh]uan*rt&`t'lh]uan*ru&`u7

The new direction the lh]uan needs to travel in when it bounces on the platform. In vector

math, this is called the
projection
:

r]njas@ena_pekj[T6Jqi^an9`ena_pekjKb?khheoekj&`t7

r]njas@ena_pekj[U6Jqi^an9`ena_pekjKb?khheoekj&`u7

The lh]uan's speed, in the direction that it's bouncing. This is known as the
tangent velocity

and it's used to calculate the platform's friction.

r]np]jcajp[Rt6Jqi^an9lh]uan*rt)jas@ena_pekj[T7

r]np]jcajp[Ru6Jqi^an9lh]uan*ru)jas@ena_pekj[U7