id stringlengths 6 6 | text stringlengths 20 17.2k | title stringclasses 1
value |
|---|---|---|
117241 | import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing';
import {COLLECTION_PATH} from '../../paths';
import {Schema} from './schema';
describe('material-table-schematic', () => {
let runner: SchematicTestRunner;
const b... | |
117246 | import { AfterViewInit, Component, ViewChild<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
import { <% if(standalone) { %>MatTableModule, <% } %>MatTable } from '@angular/material/table';
import { <% if(standalone)... | |
117247 | import { DataSource } from '@angular/cdk/collections';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { map } from 'rxjs/operators';
import { Observable, of as observableOf, merge } from 'rxjs';
// TODO: Replace this with your own data model type
ex... | |
117248 | import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
import {createTestApp} from '@angular/cdk/schematics/testing';
import {runfiles} from '@bazel/runfiles';
import {compileString} from 'sass';
import * as path from 'path';
import {createLocalAngularPackageImporter} from '../../../../.... | |
117250 | function getTestTheme() {
return `// This file was generated by running 'ng generate @angular/material:theme-color'.
// Proceed with caution if making changes to this file.
@use 'sass:map';
@use '@angular/material' as mat;
// Note: Color palettes are generated from primary: #984061
$_palettes: (
primary: (
0:... | |
117252 | # Material 3 Custom Theme schematic
```shell
ng generate @angular/material:theme-color
```
This schematic allows users to create new Material 3 theme palettes based
on custom colors by using [Material Color Utilities](https://github.com/material-foundation/material-color-utilities).
The generated [color palettes](ht... | |
117255 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
import {Schema} from './schema';
import {
... | |
117266 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/** Create custom theme for the given application configuration. */
export function createCustomTheme(name: string =... | |
117268 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Rule, SchematicsException, Tree} from '@angular-devkit/schematics';
import {
appendHtmlElementToHead,
ge... | |
117326 | extends VBoxContainer
const ROT_SPEED = 0.003
const ZOOM_SPEED = 0.5
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_MIDDLE | MOUSE_BUTTON_MASK_RIGHT
@export var camera: Camera3D
@export var camera_holder: Node3D
@export var rotation_x: Node3D
@export var node_to_move: Node3D
@export var rigid_body: R... | |
117350 | # This node converts a 3D position to 2D using a 2.5D transformation matrix.
# The transformation of its 2D form is controlled by its 3D child.
@tool
@icon("res://addons/node25d/icons/node_25d_icon.png")
class_name Node25D
extends Node2D
# SCALE is the number of 2D units in one 3D unit. Ideally, but not necessarily, ... | |
117366 | @tool
extends Control
var zoom_level := 0
var is_panning = false
var pan_center: Vector2
var viewport_center: Vector2
var view_mode_index := 0
var editor_interface: EditorInterface # Set in node25d_plugin.gd
var moving = false
@onready var viewport_2d = $Viewport2D
@onready var viewport_overlay = $ViewportOverlay
@... | |
117403 | # Handles Player-specific behavior like moving. We calculate such things with CharacterBody3D.
class_name PlayerMath25D # No icon necessary
extends CharacterBody3D
var vertical_speed := 0.0
var isometric_controls := true
@onready var _parent_node25d: Node25D = get_parent()
func _physics_process(delta: float) -> vo... | |
117404 | @tool
extends Sprite2D
const ANIMATION_FRAMERATE = 15
var _direction := 0
var _progress := 0.0
var _parent_node25d: Node25D
var _parent_math: PlayerMath25D
@onready var _stand: Texture2D = preload("res://assets/player/textures/stand.png")
@onready var _jump: Texture2D = preload("res://assets/player/textures/jump.png... | |
117405 | [gd_scene load_steps=6 format=4 uid="uid://bg27d8sfehmr4"]
[ext_resource type="Script" path="res://addons/node25d/node_25d.gd" id="1"]
[ext_resource type="Script" path="res://assets/player/player_math_25d.gd" id="3"]
[ext_resource type="Texture2D" uid="uid://bfdfertqyhf1u" path="res://assets/player/textures/jump.png" ... | |
117410 | func _ready() -> void:
# Grab focus so that the list can be scrolled (for keyboard/controller-friendly navigation).
rtl.grab_focus()
add_header("Audio")
add_line("Mix rate", "%d Hz" % AudioServer.get_mix_rate())
add_line("Output latency", "%f ms" % (AudioServer.get_output_latency() * 1000))
add_line("Output devi... | |
117414 | extends Node
func _on_open_shell_web_pressed() -> void:
OS.shell_open("https://example.com")
func _on_open_shell_folder_pressed() -> void:
var path := OS.get_environment("HOME")
if path == "":
# Windows-specific.
path = OS.get_environment("USERPROFILE")
if OS.get_name() == "macOS":
# MacOS-specific.
pat... | |
117492 | extends Area3D
var taken := false
func _on_coin_body_enter(body: Node) -> void:
if not taken and body is Player:
$Animation.play(&"take")
taken = true
# We've already checked whether the colliding body is a Player, which has a `coins` property.
# As a result, we can safely increment its `coins` property.
b... | |
117587 | class_name Player
extends CharacterBody3D
enum _Anim {
FLOOR,
AIR,
}
const SHOOT_TIME = 1.5
const SHOOT_SCALE = 2.0
const CHAR_SCALE = Vector3(0.3, 0.3, 0.3)
const MAX_SPEED = 6.0
const TURN_SPEED = 40.0
const JUMP_VELOCITY = 12.5
const BULLET_SPEED = 20.0
const AIR_IDLE_DEACCEL = false
const ACCEL = 14.0
const DEA... | |
117588 | extends Camera3D
const MAX_HEIGHT = 2.0
const MIN_HEIGHT = 0.0
var collision_exception: Array[RID] = []
@export var min_distance := 0.5
@export var max_distance := 3.5
@export var angle_v_adjust := 0.0
@export var autoturn_ray_aperture := 25.0
@export var autoturn_speed := 50.0
func _ready() -> void:
# Find collis... | |
117614 | extends VBoxContainer
func _ready() -> void:
get_viewport().size_changed.connect(_on_viewport_size_changed)
_on_viewport_size_changed()
func _process(_delta: float) -> void:
$FPS.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
func _on_viewport_size_chang... | |
117619 | extends Node
const ROT_SPEED = 0.003
const ZOOM_SPEED = 0.125
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
var tester_index := 0
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
... | |
117632 | # 3D Labels and Texts
This project showcases the two main 3D text techniques supported by Godot:
Label3D and TextMesh.
Both Label3D and TextMesh exist in 3D space and can optionally be occluded by
other objects, but they serve different use cases.
**Label3D:** The Label3D node is a 3D node like any other. It draws t... | |
117640 | extends Node
const ROT_SPEED = 0.003
const ZOOM_SPEED = 0.125
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
var tester_index := 0
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
... | |
117651 | extends Control
# Window project settings:
# - Stretch mode is set to `canvas_items` (`2d` in Godot 3.x)
# - Stretch aspect is set to `expand`
@onready var world_environment := $WorldEnvironment
@onready var directional_light := $Node3D/DirectionalLight3D
@onready var camera := $Node3D/Camera3D
@onready var fps_lab... | |
117675 | extends Camera3D
const MOUSE_SENSITIVITY = 0.002
const MOVE_SPEED = 1.5
var rot := Vector3()
var velocity := Vector3()
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event: InputEvent) -> void:
# Mouse look (only if the mouse is captured).
if event is InputEventMouseMotion an... | |
117697 | # This acts as a staging scene shown until the main scene is fully loaded.
extends Control
func _ready() -> void:
for i in 2:
# Wait 2 frames before starting to change to the main scene,
# so that the loading text can be shown instead of the splash screen.
await get_tree().process_frame
# Do not use `preload(... | |
117715 | # This script creates the ImageTexture and assigns it to an existing material at runtime.
# By not having `@tool`, this avoids saving the raw image data in the scene file,
# which would make it much larger.
extends MeshInstance3D
const TEXTURE_SIZE = Vector2i(512, 512)
const GRID_SIZE = 32
const GRID_THICKNESS = 4
fu... | |
117718 | extends Camera3D
const MOUSE_SENSITIVITY = 0.002
const MOVE_SPEED = 0.65
var rot := Vector3()
var velocity := Vector3()
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event: InputEvent) -> void:
# Mouse look (only if the mouse is captured).
if event is InputEventMouseMotion and ... | |
117743 | [gd_scene load_steps=3 format=3 uid="uid://3gkujifjokqw"]
[sub_resource type="PlaneMesh" id="1"]
[sub_resource type="ConcavePolygonShape3D" id="2"]
data = PackedVector3Array(-1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, 1, -1, 0, -1, 1, 0, -1)
[node name="StaticBodyPlane" type="StaticBody3D"]
[node name="MeshInstance3D" type... | |
117744 | [gd_scene load_steps=4 format=3 uid="uid://cl2vpuxqgnylc"]
[ext_resource type="Shape3D" path="res://assets/robot_head/godot3_robot_head_collision.tres" id="1"]
[ext_resource type="ArrayMesh" path="res://assets/robot_head/godot3_robot_head.mesh" id="2"]
[ext_resource type="PackedScene" uid="uid://3gkujifjokqw" path="re... | |
117755 | extends Test
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
var _hit_from_inside := false
var _do_raycasts := false
@onready var _raycast_visuals := ImmediateMesh.new()
@onready var _material := StandardMaterial3D.new()
func _ready() -> void:
var options: OptionMenu = $Options
options.add_... | |
117757 | [gd_scene load_steps=28 format=3 uid="uid://se7gyhmygqul"]
[ext_resource type="Script" path="res://utils/rigidbody_ground_check.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id="2"]
[ext_resource type="Script" path="res://tests/functional/test_rigidbody_grou... | |
117758 | [node name="RigidBodyConvex" type="RigidBody3D" parent="DynamicShapes/Bodies"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0)
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
physics_material_override = SubResource("13")
script = ExtResource("1")
[node name="Collisio... | |
117762 | [gd_scene load_steps=13 format=3 uid="uid://dgh5drb4q81kh"]
[ext_resource type="Script" path="res://utils/camera_orbit.gd" id="1"]
[ext_resource type="Script" path="res://tests/functional/test_moving_platform.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://b1ihqm3x8jru" path="res://tests/test_options.tscn" id=... | |
117775 | extends RigidBody3D
var _dir := 1.0
var _distance := 10.0
var _walk_spd := 100.0
var _acceleration := 22.0
var _is_on_floor := false
@onready var _forward := -transform.basis.z
@onready var _collision_shape := $CollisionShape
@onready var _material: StandardMaterial3D = $CollisionShape/MeshInstance3D.get_active_mater... | |
117783 | extends RigidBody3D
const MOUSE_DELTA_COEFFICIENT = 0.01
const CAMERA_DISTANCE_COEFFICIENT = 0.2
var _picked := false
var _last_mouse_pos := Vector2.ZERO
var _mouse_pos := Vector2.ZERO
func _ready() -> void:
input_ray_pickable = true
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if... | |
117785 | extends Node
enum PhysicsEngine {
GODOT_PHYSICS,
OTHER,
}
var _engine := PhysicsEngine.OTHER
func _enter_tree() -> void:
process_mode = Node.PROCESS_MODE_ALWAYS
# Always enable visible collision shapes on startup
# (same as the Debug > Visible Collision Shapes option).
get_tree().debug_collisions_hint = true
... | |
117788 | extends CharacterBody3D
@export var _stop_on_slopes := false
@export var use_snap := false
var _gravity := 20.0
func _physics_process(delta: float) -> void:
if is_on_floor():
floor_snap_length = 0.2
else:
velocity += Vector3.DOWN * _gravity * delta
floor_snap_length = 0.0
floor_stop_on_slope = _stop_on_slo... | |
117870 | extends Node3D
const Character = preload("res://character.gd")
var _cam_rotation := 0.0
@onready var _camera := $CameraBase/Camera3D as Camera3D
@onready var _robot := $RobotBase as Character
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_... | |
117925 | extends Camera3D
const MOUSE_SENSITIVITY = 0.002
const MOVE_SPEED = 0.6
var volumetric_fog_volume_size := int(ProjectSettings.get_setting("rendering/environment/volumetric_fog/volume_size"))
var volumetric_fog_volume_depth := int(ProjectSettings.get_setting("rendering/environment/volumetric_fog/volume_depth"))
var r... | |
117980 | extends Camera3D
var collision_exception := []
var max_height := 2.0
var min_height := 0
@export var min_distance := 0.5
@export var max_distance := 3.0
@export var angle_v_adjust := 0.0
@onready var target_node: Node3D = get_parent()
func _ready() -> void:
collision_exception.append(target_node.get_parent().get_ri... | |
118015 | [gd_scene load_steps=11 format=3 uid="uid://csdy1t6j24awl"]
[ext_resource type="Texture2D" uid="uid://c2eorasvxyf5u" path="res://menu/main/title.png" id="1"]
[ext_resource type="Script" path="res://menu/main/splash_text.gd" id="2"]
[ext_resource type="Script" path="res://menu/main/main_menu.gd" id="3"]
[ext_resource t... | |
118019 | extends CharacterBody3D
const EYE_HEIGHT_STAND = 1.6
const EYE_HEIGHT_CROUCH = 1.4
const MOVEMENT_SPEED_GROUND = 0.6
const MOVEMENT_SPEED_AIR = 0.11
const MOVEMENT_SPEED_CROUCH_MODIFIER = 0.5
const MOVEMENT_FRICTION_GROUND = 0.9
const MOVEMENT_FRICTION_AIR = 0.98
var _mouse_motion := Vector2()
var _selected_block :=... | |
118029 | [node name="TestName" type="Label" parent="."]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -192.0
offset_top = -58.0
offset_right = 192.0
offset_bottom = -24.0
grow_horizontal = 2
grow_vertical = 0
theme_override_colors/font_outline_color = Color(0, 0, 0, 1... | |
118035 | extends WorldEnvironment
const ROT_SPEED = 0.003
const ZOOM_SPEED = 0.125
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
var tester_index := 0
var rot_x := deg_to_rad(-22.5) # This must be kept in sync with RotationX.
var rot_y := deg_to_rad(90) # This must be kept ... | |
118072 | extends Camera3D
# Higher values cause the field of view to increase more at high speeds.
const FOV_SPEED_FACTOR = 60
# Higher values cause the field of view to adapt to speed changes faster.
const FOV_SMOOTH_FACTOR = 0.2
# Don't change FOV if moving below this speed. This prevents shadows from flickering when drivi... | |
118110 | [gd_scene load_steps=15 format=3 uid="uid://2y3ar4s86yra"]
[ext_resource type="Script" path="res://Main.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://dp478jyugrn7o" path="res://Player.tscn" id="2"]
[ext_resource type="PackedScene" uid="uid://ha0ar5s2c3m4" path="res://Mob.tscn" id="3"]
[ext_resource type="The... | |
118112 | [gd_scene load_steps=8 format=3 uid="uid://dp478jyugrn7o"]
[ext_resource type="Script" path="res://Player.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://d0ypm0v45pwdv" path="res://art/player.glb" id="2"]
[sub_resource type="SphereShape3D" id="1"]
radius = 0.792278
[sub_resource type="CylinderShape3D" id="2"... | |
118115 | extends CharacterBody3D
signal hit
## How fast the player moves in meters per second.
@export var speed = 14
## Vertical impulse applied to the character upon jumping in meters per second.
@export var jump_impulse = 20
## Vertical impulse applied to the character upon bouncing over a mob in meters per second.
@export... | |
118117 | extends CharacterBody3D
# Emitted when the player jumped on the mob.
signal squashed
## Minimum speed of the mob in meters per second.
@export var min_speed = 10
## Maximum speed of the mob in meters per second.
@export var max_speed = 18
func _physics_process(_delta):
move_and_slide()
func initialize(start_posi... | |
118135 | extends Camera3D
const MOUSE_SENSITIVITY = 0.002
const MOVE_SPEED = 1.5
var rot := Vector3()
var velocity := Vector3()
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event: InputEvent) -> void:
# Mouse look (only if the mouse is captured).
if event is InputEventMouseMotion and I... | |
118217 | extends CharacterBody3D
const MAX_SPEED = 3.5
const JUMP_SPEED = 6.5
const ACCELERATION = 4
const DECELERATION = 4
@onready var camera: Camera3D = $Target/Camera3D
@onready var gravity := float(-ProjectSettings.get_setting("physics/3d/default_gravity"))
@onready var start_position := position
func _physics_process(d... | |
118218 | extends Camera3D
@export var min_distance := 0.5
@export var max_distance := 3.0
@export var angle_v_adjust := 0.0
var collision_exception := []
var max_height := 2.0
var min_height := 0
@onready var target_node: Node3D = get_parent()
func _ready() -> void:
collision_exception.append(target_node.get_parent().get_r... | |
118253 | extends Button
@export_file var scene_to_change_to: String = ""
func _ready():
pressed.connect(change_scene)
func change_scene():
if not scene_to_change_to.is_empty():
get_tree().change_scene_to_file(scene_to_change_to) | |
118264 | @tool
extends Node3D
# A FABRIK IK chain with a middle joint helper.
# The delta/tolerance for the bone chain (how do the bones need to be before it is considered satisfactory)
const CHAIN_TOLERANCE = 0.01
# The amount of interations the bone chain will go through in an attempt to get to the target position
const CHA... | |
118267 | @tool
extends Node3D
@export var skeleton_path: NodePath:
set(value):
# Assign skeleton_path to whatever value is passed.
skeleton_path = value
# Because get_node doesn't work in the first call, we just want to assign instead.
# This is to get around a issue with NodePaths exposed to the editor.
if first_ca... | |
118278 | [gd_scene load_steps=6 format=3 uid="uid://d36uvu4r5qtpi"]
[ext_resource type="Script" path="res://fps/simple_bullet.gd" id="1"]
[sub_resource type="PhysicsMaterial" id="1"]
bounce = 0.5
[sub_resource type="SphereMesh" id="2"]
[sub_resource type="StandardMaterial3D" id="3"]
albedo_color = Color(0.769531, 0.486969, ... | |
118282 | extends RigidBody3D
const DESPAWN_TIME = 5
var timer = 0
func _ready():
set_physics_process(true);
func _physics_process(delta):
timer += delta
if timer > DESPAWN_TIME:
queue_free()
timer = 0 | |
118286 | [node name="Wall4" type="MeshInstance3D" parent="Level/Walls"]
transform = Transform3D(1, 0, -4.76837e-07, 0, 4, 0, 1.19209e-07, 0, 4, -19.9997, 8.00032, -21.9995)
mesh = SubResource("4")
surface_material_override/0 = SubResource("7")
[node name="StaticBody3D" type="StaticBody3D" parent="Level/Walls/Wall4"]
[node nam... | |
118350 | extends CharacterBody3D
# Moves the player
@export_range(1, 2) var player_id := 1
@export var walk_speed := 2.0
func _physics_process(_delta: float) -> void:
var move_direction := Input.get_vector(
&"move_left_player" + str(player_id),
&"move_right_player" + str(player_id),
&"move_up_player" + str(player_... | |
118354 | extends Node3D
# Handle the motion of both player cameras as well as communication with the
# SplitScreen shader to achieve the dynamic split screen effet
#
# Cameras are place on the segment joining the two players, either in the middle
# if players are close enough or at a fixed distance if they are not.
# In the fir... | |
118361 | [node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Group4/Wall5"]
shape = SubResource("9")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/Group4/Wall5" groups=["walls"]]
material_override = SubResource("33")
mesh = SubResource("11")
[node name="Wall6" type="StaticBody3D" parent="Wall... | |
118362 | [node name="Wall5" type="StaticBody3D" parent="Walls/Group6"]
transform = Transform3D(0.613129, 0, -0.789983, 0, 1, 0, 0.789983, 0, 0.613129, 5.48868, 0.5, -1.27975)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Group6/Wall5"]
shape = SubResource("9")
[node name="MeshInstance3D" type="MeshInstan... | |
118364 | extends Node2D
const PAD_SPEED = 150
const INITIAL_BALL_SPEED = 80.0
var ball_speed := INITIAL_BALL_SPEED
var screen_size := Vector2(640, 400)
# Default ball direction.
var direction := Vector2.LEFT
var pad_size := Vector2(8, 32)
@onready var ball: Sprite2D = $Ball
@onready var left_paddle: Sprite2D = $LeftPaddle
@... | |
118366 | # 2D in 3D
A demo showing how a 2D scene can be shown within a 3D scene using viewports.
Language: GDScript
Renderer: Compatibility
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2803
## How does it work?
The Pong game is rendered to a custom
[`Viewport`](https://docs.godote... | |
118377 | [gd_scene load_steps=11 format=3 uid="uid://xwkspajfdmd7"]
[ext_resource type="Script" path="res://3d_in_2d.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://q5bonn8iowbc" path="res://robot_demo.png" id="2"]
[ext_resource type="PackedScene" uid="uid://8nlipuu0ceal" path="res://robot_3d.tscn" id="3"]
[sub_resource... | |
118379 | # 3D in 2D
A demo showing how a 3D scene can be shown within a 2D one using viewports.
Language: GDScript
Renderer: Compatibility
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2804
## How does it work?
The 3D robot is rendered to a custom
[`Viewport`](https://docs.godotengi... | |
118382 | extends Node2D
@onready var viewport: SubViewport = $SubViewport
@onready var viewport_initial_size: Vector2i = viewport.size
@onready var viewport_sprite: Sprite2D = $ViewportSprite
func _ready() -> void:
$AnimatedSprite2D.play()
get_viewport().size_changed.connect(_root_viewport_size_changed)
# Called when the... | |
118391 | extends Node3D
## Used for checking if the mouse is inside the Area3D.
var is_mouse_inside := false
## The last processed input touch/mouse event. Used to calculate relative movement.
var last_event_pos2D := Vector2()
## The time of the last event in seconds since engine start.
var last_event_time := -1.0
@onready ... | |
118421 | extends VBoxContainer
func _ready() -> void:
# Don't allow loading files that don't exist yet.
($SaveLoad/LoadConfigFile as Button).disabled = not FileAccess.file_exists("user://save_config_file.ini")
($SaveLoad/LoadJSON as Button).disabled = not FileAccess.file_exists("user://save_json.json")
func _on_open_user... | |
118429 | extends Button
# This script shows how to save data using Godot's custom ConfigFile format.
# ConfigFile can store any Variant type except Signal or Callable.
# It can even store Objects, but be extra careful where you deserialize them
# from, because they can include (potentially malicious) scripts.
const SAVE_PATH =... | |
118434 | extends Panel
func _on_goto_scene_pressed() -> void:
# Change the scene to the one located at the given path.
get_tree().change_scene_to_file("res://scene_b.tscn") | |
118436 | extends Panel
func _on_goto_scene_pressed() -> void:
# Change the scene to the given PackedScene.
# Though it usually takes more code, this can have advantages, such as letting you load the
# scene in another thread, or use a scene that isn't saved to a file.
var scene: PackedScene = load("res://scene_a.tscn")
ge... | |
118439 | ; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Scene Changer"
config/descriptio... | |
118454 | extends Control
var thread: Thread
func _on_load_pressed() -> void:
if is_instance_valid(thread) and thread.is_started():
# If a thread is already running, let it finish before we start another.
thread.wait_to_finish()
thread = Thread.new()
print_rich("[b]Starting thread.")
# Our method needs an argument, so ... | |
118462 | extends Node
# Changing scenes is most easily done using the `change_scene_to_file()` and
# `change_scene_to_packed()` methods of SceneTree. This script demonstrates
# how to change scenes without those helpers.
func goto_scene(path: String) -> void:
# This function will usually be called from a signal callback,
# ... | |
118498 | extends Control
@onready var client: Node = $Client
@onready var host: LineEdit = $VBoxContainer/Connect/Host
@onready var room: LineEdit = $VBoxContainer/Connect/RoomSecret
@onready var mesh: CheckBox = $VBoxContainer/Connect/Mesh
func _ready() -> void:
client.lobby_joined.connect(_lobby_joined)
client.lobby_seale... | |
118511 | [gd_scene load_steps=3 format=3 uid="uid://c5m3rogpaglk1"]
[ext_resource type="Texture2D" uid="uid://bdomqql6y50po" path="res://brickfloor.png" id="1"]
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(48, 48)
[node name="TileScene" type="Node2D"]
[node name="Wall" type="Sprite2D" parent="."]
position = ... | |
118581 | extends CharacterBody3D
# Settings to control the character.
@export var rotation_speed := 1.0
@export var movement_speed := 5.0
@export var movement_acceleration := 5.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity := float(ProjectSettings.get_setting("physics/3d/default_... | |
118598 | extends XROrigin3D
# Settings to control the character.
@export var rotation_speed := 1.0
@export var movement_speed := 5.0
@export var movement_acceleration := 5.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity := float(ProjectSettings.get_setting("physics/3d/default_gravi... | |
118625 | extends RigidBody3D
class_name PickupAbleBody3D
var highlight_material : Material = preload("res://shaders/highlight_material.tres")
var picked_up_by : Area3D
var closest_areas : Array
var original_parent : Node3D
var tween : Tween
# Called when this object becomes the closest body in an area
func add_is_closest(ar... | |
118626 | [gd_scene load_steps=3 format=3 uid="uid://byif52d1xkl3u"]
[ext_resource type="Script" path="res://pickup/pickup_handler.gd" id="1_5qec3"]
[sub_resource type="SphereShape3D" id="SphereShape3D_i5on0"]
resource_local_to_scene = true
margin = 0.001
radius = 0.3
[node name="PickupHandler" type="Area3D"]
script = ExtReso... | |
118627 | @tool
extends Area3D
class_name PickupHandler3D
# This area3D class detects all physics bodys based on
# PickupAbleBody3D within range and handles the logic
# for selecting the closest one and allowing pickup
# of that object.
# Detect range specifies within what radius we detect
# objects we can pick up.
@export var... | |
118629 | [gd_resource type="Shader" format=3 uid="uid://cs1jlvgrhd4ac"]
[resource]
code = "// NOTE: Shader automatically converted from Godot Engine 4.3.beta1's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_front, diffuse_burley, specular_schlick_ggx, unshaded;
uniform vec4 albedo : ... | |
118651 | [gd_scene load_steps=5 format=3 uid="uid://cenb0bfok13vx"]
[ext_resource type="Script" path="res://ui.gd" id="1_wnf2v"]
[ext_resource type="Shader" path="res://cursor.gdshader" id="2_hngl5"]
[sub_resource type="LabelSettings" id="LabelSettings_cnxo1"]
font_size = 64
[sub_resource type="ShaderMaterial" id="ShaderMate... | |
118725 | @tool
extends Area3D
############################################################################
# Water ripple effect shader - Bastiaan Olij
#
# This is an example of how to implement a more complex compute shader
# in Godot and making use of the new Custom Texture RD API added to
# the RenderingServer.
#
# If threa... | |
118727 | shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
uniform vec3 albedo : source_color;
uniform float metalic : hint_range(0.0, 1.0, 0.1) = 0.8;
uniform float roughness : hint_range(0.0, 1.0, 0.1) = 0.2;
uniform sampler2D effect_texture;
uniform vec2 effect_t... | |
118742 | [gd_scene load_steps=4 format=3 uid="uid://csyb8ij530w1l"]
[sub_resource type="StandardMaterial3D" id="1"]
diffuse_mode = 1
albedo_color = Color(0.149414, 0.796875, 0.569252, 1)
roughness = 0.0
[sub_resource type="BoxMesh" id="2"]
[sub_resource type="Environment" id="Environment_wokxq"]
ambient_light_source = 2
ambi... | |
118849 | [node name="RichTextLabel" type="RichTextLabel" parent="MainPanel/HSplitContainer/BasicControls/VBoxContainer/TabContainer/Tab 4/MarginContainer"]
layout_mode = 2
focus_mode = 2
bbcode_enabled = true
text = "[center]RichTextLabel: [color=#f88]Tab 4[/color] is selected.[/center]"
context_menu_enabled = true
selection_en... | |
118859 | extends ColorPickerButton
# Returns the data to pass from an object when you click and drag away from
# this object. Also calls `set_drag_preview()` to show the mouse dragging
# something so the user knows that the operation is working.
func _get_drag_data(_at_position: Vector2) -> Color:
# Use another colorpicker as... | |
118864 | # The root Control node ("Main") and AspectRatioContainer nodes are the most important
# pieces of this demo.
# Both nodes have their Layout set to Full Rect
# (with their rect spread across the whole viewport, and Anchor set to Full Rect).
extends Control
var base_window_size := Vector2(
ProjectSettings.get_setting... | |
118865 | # Multiple Resolutions and Aspect Ratios
**Note:** This demo is intended to showcase what Godot can do in terms of
supporting multiple resolutions and aspect ratios. As such, this demo very
full-featured but it's also fairly complex to understand.
If you're in a hurry and want to implement *decent* support for multip... | |
118867 | ; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Multiple Resolutions and Aspect ... | |
118890 | [gd_scene load_steps=4 format=2]
[ext_resource path="res://ball.png" type="Texture2D" id=1]
[ext_resource path="res://logic/Ball.cs" type="Script" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 4.65663
[node name="Ball" type="Area2D"]
script = ExtResource( 2 )
[node name="Sprite2D" type="Sprite2D" parent="... | |
118909 | [gd_scene load_steps=12 format=3 uid="uid://bufr8nynnqrj"]
[ext_resource type="Script" path="res://Logic/Paddle.cs" id="1"]
[ext_resource type="Texture2D" uid="uid://cgbjbhglgxf0k" path="res://paddle.png" id="2"]
[ext_resource type="Script" path="res://Logic/Ball.cs" id="4"]
[ext_resource type="Texture2D" uid="uid://1... | |
118931 | @tool
extends Control
var zoom_level := 0
var is_panning = false
var pan_center: Vector2
var viewport_center: Vector2
var view_mode_index := 0
var editor_interface: EditorInterface # Set in node25d_plugin.gd
var moving = false
@onready var viewport_2d = $Viewport2D
@onready var viewport_overlay = $ViewportOverlay
@o... | |
118959 | [gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/node25d-cs/Node25D.cs" type="Script" id=1]
[ext_resource path="res://addons/node25d-cs/icons/node_25d_icon.png" type="Texture2D" id=2]
[ext_resource path="res://assets/player/PlayerMath25D.cs" type="Script" id=3]
[ext_resource path="res://assets/player/... | |
119002 | extends Game
func _ready() -> void:
var player_2 := %Player2 as Player
var viewport_1 := %Viewport1 as SubViewport
var viewport_2 := %Viewport2 as SubViewport
viewport_2.world_2d = viewport_1.world_2d
player_2.camera.custom_viewport = viewport_2
player_2.camera.make_current() | |
119066 | [gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://djwm5nol3d801"]
[sub_resource type="Shader" id="1"]
code = "// original wind shader from https://github.com/Maujoe/godot-simple-wind-shader-2d/tree/master/assets/maujoe.simple_wind_shader_2d
// original script modified by HungryProton so that the asse... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.