When player hits a key, check to see which way they are facing and deliver a force-push to pushable objects:
var collider = right_cast.get_collider()
#check if this is okay
if collider is Node && collider is RigidBody2D && collider.is_in_group("pushable"):
pushTarget = collider
pushEnabled = true
if left_cast.is_colliding() && facing==FaceDirection.LEFT:
var collider = left_cast.get_collider()
if collider is Node && collider is RigidBody2D && collider.is_in_group("pushable"):
pushTarget = collider
pushEnabled = true
if not right_cast.is_colliding() && not left_cast.is_colliding():
pushEnabled = false```
When player hits a key, check to see which way they are facing and deliver a force-push to pushable objects:
```if right_cast.is_colliding() && facing==FaceDirection.RIGHT:
var collider = right_cast.get_collider()
#check if this is okay
if collider is Node && collider is RigidBody2D && collider.is_in_group("pushable"):
pushTarget = collider
pushEnabled = true
if left_cast.is_colliding() && facing==FaceDirection.LEFT:
var collider = left_cast.get_collider()
if collider is Node && collider is RigidBody2D && collider.is_in_group("pushable"):
pushTarget = collider
pushEnabled = true
if not right_cast.is_colliding() && not left_cast.is_colliding():
pushEnabled = false```
Also map the shove control to deliver the impulse:
if Input.is_action_just_pressed("shove") && pushEnabled:
print("I want to shove")
var shoveDirection:int
match facing:
FaceDirection.RIGHT:
shoveDirection = 1
FaceDirection.LEFT:
shoveDirection = -1
current_state = State.SHOVE
pushTarget.apply_central_impulse(Vector2(shoveDirection,0)*700)
Also map the shove control to deliver the impulse:
```
if Input.is_action_just_pressed("shove") && pushEnabled:
print("I want to shove")
var shoveDirection:int
match facing:
FaceDirection.RIGHT:
shoveDirection = 1
FaceDirection.LEFT:
shoveDirection = -1
current_state = State.SHOVE
pushTarget.apply_central_impulse(Vector2(shoveDirection,0)*700)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When player hits a key, check to see which way they are facing and deliver a force-push to pushable objects:
Also map the shove control to deliver the impulse: