# 2D Swimming.. (Godot 3.5)

Attention Topic was automatically imported from the old Question2Answer platform.

Node2d(renamed temp)
two platforms
(between them)
Area 2D
tilemap (to draw the water)
collisonshape2d (across the top row)
and my character (with script)
so far i got my player to walk on the platforms

what i need help with is when my character hits the water
how do i *check to see if the character is in the water
*move my character while in the water.
here is my character script

enum States {AIR = 1, FLOOR, LADDER, WALL, }
var state = States.AIR
var velocity = Vector2(0,0)

const GRAVITY = 35
const JUMPFORCE = -1100
const RUNSPEED = 400
const SPEED = 210

func _physics_process(delta):
match state:
States.AIR:
if is_on_floor():
state = States.FLOOR
continue

``````		\$Sprite.play("Air")
if Input.is_action_pressed("Right"):
velocity.x = lerp(velocity.x,SPEED,0.1) if velocity.x < SPEED else lerp(velocity.x, SPEED, 0.01)
\$Sprite.flip_h = false
elif Input.is_action_pressed("Left"):
velocity.x = lerp(velocity.x,-SPEED,0.1) if velocity.x > -SPEED else lerp(velocity.x,-SPEED,0.01)
\$Sprite.flip_h = true
else:
velocity.x = lerp(velocity.x,0,0.2)
move_and_fall()
fire()

States.FLOOR:
if not is_on_floor():
state = States.AIR
continue

if Input.is_action_pressed("Right"):
if Input.is_action_pressed("run"):
velocity.x = lerp(velocity.x,RUNSPEED,0.1)
\$Sprite.set_speed_scale(1.8)
else:
velocity.x = lerp(velocity.x,SPEED,0.1)
\$Sprite.set_speed_scale(1.0)
\$Sprite.play("Walk")
\$Sprite.flip_h = false
elif Input.is_action_pressed("Left"):
if Input.is_action_pressed("run"):
velocity.x = lerp(velocity.x,-RUNSPEED,0.1)
\$Sprite.set_speed_scale(1.8)
else:
velocity.x = -SPEED
\$Sprite.set_speed_scale(1.0)
\$Sprite.play("Walk")
\$Sprite.flip_h = true
else:
\$Sprite.play("Idle")
velocity.x = lerp(velocity.x, 0,0.2)

if Input.is_action_just_pressed("Jump"):
velocity.y = JUMPFORCE
\$SoundJump.play()
state = States.AIR

move_and_fall()
fire()
``````

func fire():
if Input.is_action_just_pressed(“fire”):
var direction = 1 if not \$Sprite.flip_h else -1
var f = FIREBALL.instance()
f.direction = direction
``````velocity = move_and_slide(velocity,Vector2.UP)