-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Unity Virtual Reality Projects
By :

A trampoline differs from a bouncy ball because the former makes things that collide with it bounce instead of itself bouncing. Unity doesn't do this automatically for us, So, we need to use scripting.
Feature: When a brick drops from mid-air onto a trampoline, it bounces up, diminished by gravity.
Build the scene and turn the target into a trampoline, as follows:
Navigate to File | Save Scene As and name it BrickTrampoline
.
Delete the BallGame
script component from GameController
using gear icon | Remove Component. We won't need it.
Rename the Target
object to Trampoline
.
Set its Position to (0
, 0.2
, 0
).
To create the brick, navigate to GameObject | 3D Object | Cube and rename it to Brick
.
Set its Scale to (0.25
, 0.5
, 1
) and Position to (0
, 5
, 0
).
Drag the Red
material onto it.
Add a Rigidbody by navigating to Add Component | Physics | Rigidbody.
When you play now, the brick drops to a dead stop. Make a new script on trampoline, as follows:
With Trampoline
selected in Hierarchy...