class
Eagle::KinematicBody3D
Overview
A 3D body moved from code that slides along obstacles: first- and third-person characters and moving platforms.
class Walker < KinematicBody3D
def ready : Nil
box(0.6, 1.8, 0.6)
end
def physics_process(dt : Float32) : Nil
input = Input.vector("left", "right", "up", "down")
self.velocity = v3(input.x * 5, velocity.y - 20 * dt, input.y * 5)
self.velocity = v3(velocity.x, 8, velocity.z) if on_floor? && Input.pressed?("jump")
move_and_slide(dt)
end
end
Defined in:
eagle/nodes/physics3d_nodes.crConstructors
-
.new(name : String = "", position : Vec3 = Vec3::ZERO, shape : Physics3D::Shape | Nil = nil)
Creates a kinematic body.
Instance Method Summary
-
#floor_max_angle : Float32
Steepest slope that still counts as floor, in radians.
-
#floor_max_angle=(floor_max_angle : Float32)
Steepest slope that still counts as floor, in radians.
-
#floor_normal : Vec3
The normal of the floor under the body.
-
#floor_snap : Float32
How far below the body to look for ground each move.
-
#floor_snap=(floor_snap : Float32)
How far below the body to look for ground each move.
-
#move_and_slide(dt : Float32, velocity : Vec3 | Nil = nil) : Vec3
Moves by
velocity * dt, sliding along obstacles, and updates the floor, wall and ceiling flags. -
#on_ceiling? : Bool
True when the last move hit a ceiling.
-
#on_floor? : Bool
True when the last move ended on a floor.
-
#on_wall? : Bool
True when the last move hit a wall.
-
#physics_process(dt : Float32) : Nil
Keeps the body in sync with the node.
-
#up_direction : Vec3
Which way is up, used to tell floors from ceilings.
-
#up_direction=(up_direction : Vec3)
Which way is up, used to tell floors from ceilings.
-
#velocity : Vec3
Velocity in meters per second, used by
#move_and_slide. -
#velocity=(velocity : Vec3)
Velocity in meters per second, used by
#move_and_slide.
Instance methods inherited from class Eagle::CollisionObject3D
add_shape(s : Physics3D::Shape) : self
add_shape,
body : Physics3D::Body
body,
body_entered : Eagle::Emitter(CollisionObject3D)
body_entered,
body_exited : Eagle::Emitter(CollisionObject3D)
body_exited,
box(w : Number, h : Number, d : Number) : selfbox(size : Vec3, offset : Vec3 = Vec3::ZERO) : self box, debug=(debug : Bool) debug=, debug? : Bool debug?, emit_body_entered(*args) : Nil emit_body_entered, emit_body_exited(*args) : Nil emit_body_exited, enter_tree : Nil enter_tree, exit_tree : Nil exit_tree, layer : UInt32 layer, layer=(v : UInt32) layer=, mask : UInt32 mask, mask=(v : UInt32) mask=, on_body_entered(&block : CollisionObject3D -> Nil) : Proc(CollisionObject3D, Nil) on_body_entered, on_body_exited(&block : CollisionObject3D -> Nil) : Proc(CollisionObject3D, Nil) on_body_exited, overlapping : Array(CollisionObject3D) overlapping, physics_process(dt : Float32) : Nil physics_process, process(dt : Float32) : Nil process, pull_transform : Nil pull_transform, push_transform : Nil push_transform, sphere(radius : Number, offset : Vec3 = Vec3::ZERO) : self sphere, world : Physics3D::World world, world=(world : Physics3D::World) world=
Constructor methods inherited from class Eagle::CollisionObject3D
new(type : Physics3D::BodyType, name : String = "", position : Vec3 = Vec3::ZERO, shape : Physics3D::Shape | Nil = nil)
new
Instance methods inherited from class Eagle::Node3D
back : Vec3
back,
distance_to(o : Node3D) : Float32
distance_to,
draw_tree(g : Graphics) : Nil
draw_tree,
euler : Vec3
euler,
euler=(e : Vec3)
euler=,
forward : Vec3
forward,
global_position : Vec3
global_position,
global_position=(p : Vec3)
global_position=,
global_rotation : Quat
global_rotation,
global_transform : Mat4
global_transform,
look_at(target : Vec3, up : Vec3 = Vec3::UP) : Nil
look_at,
parent_3d : Node3D | Nil
parent_3d,
position : Vec3
position,
position=(position : Vec3)
position=,
right : Vec3
right,
rotate(axis : Vec3, rad : Number) : Nil
rotate,
rotate_local(axis : Vec3, rad : Number) : Nil
rotate_local,
rotate_x(rad : Number) : Nil
rotate_x,
rotate_y(rad : Number) : Nil
rotate_y,
rotate_z(rad : Number) : Nil
rotate_z,
rotation : Quat
rotation,
rotation=(rotation : Quat)
rotation=,
scale : Vec3
scale,
scale=(s : Vec3)scale=(s : Number) scale=, set_euler(pitch : Number, yaw : Number, roll : Number = 0) : self set_euler, to_global(local : Vec3) : Vec3 to_global, to_local(global : Vec3) : Vec3 to_local, top_level=(top_level : Bool) top_level=, top_level? : Bool top_level?, transform : Mat4 transform, translate(v : Vec3) : Nil translate, translate_local(v : Vec3) : Nil translate_local, up : Vec3 up
Constructor methods inherited from class Eagle::Node3D
new(name : String = "", position : Eagle::Vec3 = Vec3::ZERO, rotation : Eagle::Quat = Quat::IDENTITY, scale : Eagle::Vec3 = Vec3::ONE)
new
Instance methods inherited from class Eagle::Node
<<(child : Node) : self
<<,
[](path : String) : Node
[],
[]?(path : String) : Node | Nil
[]?,
add(child : Node) : Nodeadd(*children : Node) : Nil add, add_child(child : Node) : Node add_child, add_to_group(group : String) : self add_to_group, ancestor_of?(node : Node) : Bool ancestor_of?, can_process? : Bool can_process?, child?(name : String) : Node | Nil child?, child_added : Eagle::Emitter(Node) child_added, child_count : Int32 child_count, child_removed : Eagle::Emitter(Node) child_removed, children : Array(Eagle::Node) children, children_of(type : T.class) : Array(T) forall T children_of, clear_children : Nil clear_children, draw(g : Graphics) : Nil draw, dump(io : IO = STDOUT, indent = 0) : Nil dump, each_ancestor(& : Node -> ) : Nil each_ancestor, each_child(& : Node -> ) : Nil each_child, each_descendant(&block : Node -> ) : Nil each_descendant, emit_child_added(*args) : Nil emit_child_added, emit_child_removed(*args) : Nil emit_child_removed, emit_tree_entered(*args) : Nil emit_tree_entered, emit_tree_exited(*args) : Nil emit_tree_exited, enter_tree : Nil enter_tree, exit_tree : Nil exit_tree, find(name : String) : Node | Nil find, find_all(type : T.class) : Array(T) forall T find_all, first_child : Node | Nil first_child, free : Nil free, get_node(path : String, type : T.class) : T forall T
get_node(path : String) : Node get_node, get_node?(path : String) : Node | Nil get_node?, groups : Set(String) groups, in_group?(group : String) : Bool in_group?, in_tree? : Bool in_tree?, input(event : Event) : Nil input, name : String name, name=(name : String) name=, on_child_added(&block : Node -> Nil) : Proc(Node, Nil) on_child_added, on_child_removed(&block : Node -> Nil) : Proc(Node, Nil) on_child_removed, on_tree_entered(&block : -> Nil) : Proc(Nil) on_tree_entered, on_tree_exited(&block : -> Nil) : Proc(Nil) on_tree_exited, parent : Node | Nil parent, path : String path, physics_process(dt : Float32) : Nil physics_process, process(dt : Float32) : Nil process, process_mode : Eagle::Node::ProcessMode process_mode, process_mode=(process_mode : Eagle::Node::ProcessMode) process_mode=, queue_free : Nil queue_free, queued_free? : Bool queued_free?, ready : Nil ready, ready_called? : Bool ready_called?, remove(child : Node) : Nil remove, remove_child(child : Node) : Nil remove_child, remove_from_group(group : String) : Nil remove_from_group, remove_from_parent : Nil remove_from_parent, resized(width : Int32, height : Int32) : Nil resized, root : Node root, to_s(io : IO) : Nil to_s, tree_entered : Eagle::Emitter() tree_entered, tree_exited : Eagle::Emitter() tree_exited, visible=(visible : Bool) visible=, visible? : Bool visible?, z_index : Int32 z_index, z_index=(z_index : Int32) z_index=
Constructor methods inherited from class Eagle::Node
new(name : String = "")
new
Constructor Detail
Creates a kinematic body.
Instance Method Detail
Steepest slope that still counts as floor, in radians.
Moves by velocity * dt, sliding along obstacles, and updates the floor, wall and
ceiling flags. Returns the new velocity.