User Tools

Site Tools


godot_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
godot_notes [2024/03/18 12:24]
admin removed
— (current)
Line 1: Line 1:
-===== Part 1 ===== 
-  - New scene: click 3D Scene, rename to '​world'​ 
-  - Create floor. ​ Add MeshInstance3D to scene 
-  - Set Mesh type to 'New PlaneMesh'​ 
-  - Change size.  Transform -> scale to 20 
-  - Create collision mesh.  Using the '​Mesh'​ top button, choose '​Trimesh Static Body'​. ​ That automatically creates a StaticBody3D of the correct type, and then adds a CollisionShape3D. 
-  - New wall.  Create another new mesh.  This time the Mesh should be New BoxMesh'​. ​ Move walls to edge, set z to 20 
-  - Tweak the wall height, 'y to the sky', set to 10 
-  - Duplicate for the other three walls 
  
-===== Part 2 ===== 
-  - New scene. ​ Click + next to the world scene. ​ Other node.  Search for CharacterBody3D. ​ Name it '​player'​. 
-  - Add subnode. ​ Click +, search for MeshInstance3D. ​ Set Mesh shape to Capsule shape. 
-  - Fix the height. ​ Transform, adjust Y to 1m. 
-  - Select player node, add new node, Camera3D. 
-  - Adjust Camera height to eye height. 
-  - Create script. ​ Select player node.  Use script+/​scroll button. ​ Select a template for Basic movement. 
-  - Add new variable. ​ ''​const TURN_SPEED = 0.05''​ 
-  - Add new code 
-<​code>​ 
-if Input.is_action_pressed("​ui_left"​):​ 
-  self.rotate_y(TURN_SPEED) 
-if Input.is_action_pressed("​ui_right"​):​ 
-  self.rotate_y(-TURN_SPEED) 
-</​code>​ 
-  - Comment out the jump code 
-  - In the world scene, drag the player scene into the world 
-  - In the three dot menu (world scene), use 'Add Sun to scene',​ 'add environment to scene' 
-  - In the player scene, use the Mesh button to add a '​Simplified Convext Collision Sibling'​ mesh to the player'​s MeshInstance3D 
-  - Set up WASD controls in the Project Settings 
- 
-==== Part 3 ==== 
-  - Import a texture by dragging it into the file system. 
-  - Select a wall.  Use Geometry -> Material Override. ​ Select New StandardMaterial3D. ​ Click the sphere. ​ Expand Albedo. ​ Drag the texture to the '​Texture'​ input. 
-  - Find UV1, experiment with the sizing, approx 30 x 10 
-  - Apply to floor/other walls. 
- 
-==== Part 4 ==== 
-  - Create new scene, other node: '​CanvasLayer',​ rename to '​ui'​ 
-  - Create new node, AnimatedSprite2D 
-  - Create new node, ColorRect 
-  - In 2D view, size the ColorRect. ​ Layout -> Anchors -> Bottom Wide.  Set the colour to dark blue. 
-  - Import wolfweapons.png 
-  - Select Animated Sprite. ​ Expand Animation -> Sprite Frame. ​ Click New SpriteFrames. ​ Click it again to view the animation frame at the bottom. 
-  - Rename default to '​knife_idle',​ set as default. 
-  - Click grid, adjust, set up idle frame. 
-  - Adjust position of animatedspirteframe in 2D view, use Transform->​Scale to size up to 5 
-  - Create new animation called '​stab'​ 
-  - Add new stab animations, disable loop, set FPS to 16 
-  - Click UI root node, add script. Enter the following code: 
-<code file ui.gd> 
-extends CanvasLayer 
- 
-var ammo = 0 
-var current_weapon = "​knife"​ 
- 
-func _ready(): 
- $AnimatedSprite2D.animation_finished.connect(_on_AnimatedSprite2D_animation_finished) 
- 
-func _process(delta):​ 
- if Input.is_action_just_pressed("​ui_select"​):​ 
- if current_weapon == "​knife":​ 
- $AnimatedSprite2D.play("​stab"​) 
- elif current_weapon == "​gun":​ 
- if ammo > 0: 
- $AnimatedSprite2D.play("​shoot"​) 
- ammo -= 1 
- 
-func _on_AnimatedSprite2D_animation_finished():​ 
- if current_weapon == "​knife":​ 
- $AnimatedSprite2D.play("​knife_idle"​) 
- elif current_weapon == "​gun":​ 
- $AnimatedSprite2D.play("​gun_idle"​) 
- 
- 
-</​code>​