Ability to keep collisionshapes and collisionpolygons when running the game.
Works for 2D and 3D These are still just helpers in case you want to animate them or access them directly. Modifying the real shapes is still done via CollisionObject and CollisionObject2D APIs But an API was added so you can query which shapes from CollisionObject correspond to which CollisionShape. Have Fun!
This commit is contained in:
21
demos/2d/dynamic_collision_shapes/ball.gd
Normal file
21
demos/2d/dynamic_collision_shapes/ball.gd
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
|
||||
var timeout=5
|
||||
|
||||
func _process(delta):
|
||||
timeout-=delta
|
||||
if (timeout<1):
|
||||
set_opacity(timeout)
|
||||
if (timeout<0):
|
||||
queue_free()
|
||||
func _ready():
|
||||
set_process(true)
|
||||
# Initialization here
|
||||
pass
|
||||
|
||||
|
||||
BIN
demos/2d/dynamic_collision_shapes/ball.png
Normal file
BIN
demos/2d/dynamic_collision_shapes/ball.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 321 B |
BIN
demos/2d/dynamic_collision_shapes/ball.scn
Normal file
BIN
demos/2d/dynamic_collision_shapes/ball.scn
Normal file
Binary file not shown.
BIN
demos/2d/dynamic_collision_shapes/box.png
Normal file
BIN
demos/2d/dynamic_collision_shapes/box.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 253 B |
BIN
demos/2d/dynamic_collision_shapes/circle.png
Normal file
BIN
demos/2d/dynamic_collision_shapes/circle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 889 B |
23
demos/2d/dynamic_collision_shapes/dynamic_colobjs.gd
Normal file
23
demos/2d/dynamic_collision_shapes/dynamic_colobjs.gd
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
const EMIT_INTERVAL=0.1
|
||||
var timeout=EMIT_INTERVAL
|
||||
|
||||
func _process(delta):
|
||||
timeout-=delta
|
||||
if (timeout<0):
|
||||
timeout=EMIT_INTERVAL
|
||||
var ball = preload("res://ball.scn").instance()
|
||||
ball.set_pos( Vector2(randf() * get_viewport_rect().size.x, 0) )
|
||||
add_child(ball)
|
||||
|
||||
func _ready():
|
||||
set_process(true)
|
||||
# Initialization here
|
||||
pass
|
||||
|
||||
|
||||
BIN
demos/2d/dynamic_collision_shapes/dynamic_colobjs.scn
Normal file
BIN
demos/2d/dynamic_collision_shapes/dynamic_colobjs.scn
Normal file
Binary file not shown.
4
demos/2d/dynamic_collision_shapes/engine.cfg
Normal file
4
demos/2d/dynamic_collision_shapes/engine.cfg
Normal file
@ -0,0 +1,4 @@
|
||||
[application]
|
||||
|
||||
name="Run-Time CollisionShape"
|
||||
main_scene="res://dynamic_colobjs.scn"
|
||||
BIN
demos/2d/dynamic_collision_shapes/poly.png
Normal file
BIN
demos/2d/dynamic_collision_shapes/poly.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user