Power-Ups
Power ups gives the player temporary abilities that changes the gameplay. It can change the character size, trigger flying, change sprint speed, render objects that follow the player and much more!
An ability consists of one or many effects. You can choose to use pre-existing abilities or create your own custom effects.
In short: A Power-Up gives abilities that consist of effects.
Examples
Dynamite that gives flying ability
import { HNode, PowerUp, Prefab, render } from '@hiber3d/hdk-react';
import { Ground } from '@hiber3d/hdk-react-components';
const World = () => (
<HNode>
<PowerUp abilities={['a_powerup_flying_01']} z={5} y={1}>
<Prefab id="gpl_dynamite_01" />
</PowerUp>
<Ground repeatX={0} repeatZ={0} />
</HNode>
);
render(<World />, {
environment: 'midday_01',
});
The above example uses a built in ability a_powerup_flying_01
. This ability consists of several effects under the hood, including:
- Flying movement mode:
e_flying_01
- FX effect that renders wind particles:
e_fx_speed_lines_01
- Flying sound effect:
e_sound_flying_01
- A light camera shake:
e_camera_shake_01
Check below for a list of available predefined abilitiy and effects.
A lantern that follows the player
import { HNode, PointLight, PowerUp, Prefab, PrefabDefinition, render } from '@hiber3d/hdk-react';
import { PointSound } from '@hiber3d/hdk-react-components';
const World = () => (
<HNode>
<PrefabDefinition id="carryingLantern">
<PointLight z={-1} y={2} rotX={-90} strength={10} radius={8} color={[0.995, 0.439, 0]} />
<PointSound src={{ id: 'a_fx_bonfire_01' }} />
<PointSound src={{ id: 'a_fx_lever_01' }} looping={false} />
<Prefab id="en_p_lantern_02" y={1.6} scale={0.4} x={-0.4} z={0.3} />
</PrefabDefinition>
<PowerUp
z={5}
abilities={[
{
effects: [
{
duration: 8,
stackRule: 'UNSTACKABLE',
attributes: {
type: 'FX',
data: {
onActiveVfxPrefabId: 'carryingLantern',
},
},
},
],
},
]}>
<Prefab id="en_p_lantern_02" scale={0.5} y={1} />
</PowerUp>
<Prefab id="plane_01" material="t_bark_05" y={-2} />
</HNode>
);
render(<World />, {
environment: 'dark_night_01',
});
In the example above we define a custom ability that consists of one effect. The effect is a FX
effect that renders a custom prefab when the ability is active. The custom prefab is defined using the PrefabDefinition
component.
Predefined abilities and effects
Check the following files for predefined ability and effect ids:
import { abilities, effects } from '@hiber3d/hdk-core';
Available effect types
Check the Effects
type for available effects and their attributes:
import { Effects } from '@hiber3d/hdk-core';