![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Mateus Felipe C. C. |
I’ve made an Scene called WorldBlock, which will be the basis for a series of blocks with common behaviour. This Scene structure is simply a RigidBody2D
with the following attached script:
extends Node2D
enum BlockMaterial {
Wood,
Metal,
}
export (BlockMaterial) var blockMaterial
export (int) var initialResistance
signal damage
Now, I want to create a block based on this one. I created a block called Bomb
, and the strucure is as follows:
- Link to WorldBlock
- Sprite
- Explosion Area (Area2D)
- Area (CircleShape2D)
- Explosion (Particles2D)
- CollisionShape2D
- Countdown (Timer)
And the script is, currently, as follows:
extends "res://WorldBlock.gd"
const WorldBlock = preload("res://WorldBlock.gd")
var blowing = false
func _ready():
$Countdown.connect("timeout", self, "_blow")
connect("damage", self, "_blow")
func _blow():
if blowing:
return
blowing = true
$Sprite.hide()
$CollisionShape2D.queue_free()
$Explosion.emitting = true
$Countdown.disconnect("timeout", self, "_blow")
$Countdown.connect("timeout", self, "queue_free")
$Countdown.wait_time = 2
$Countdown.start()
var within = $ExplosionArea.get_overlapping_bodies()
for item in within:
if item is WorldBlock and item != self:
item.emit_signal("damage")
func _integrate_forces(state):
set_applied_force(Vector2(1.0, 0.0))
However, I get the following error: error(26,38): Method 'set_applied_force' is not declared in the current class.
Why I get this if WorldBlock is a RigidBody2D
? How can I apply the force within my block?