|
|
|
 |
Reply From: |
Lgdn |
hi,welcome to,godot,show me your script and your screen
Alright, this is my code:
extends KinematicBody2D
enum {
WATER,
GAS,
ICE
}
var velocity = Vector2(0,0)
const speed = 300
const gravity = 30
const jump = -700
var state = WATER
func state(state):
match state:
WATER:
_physics_process(_delta)
GAS:
pass
ICE:
pass
func _physics_process(_delta):
if Input.is_action_pressed("right"):
velocity.x = speed
$Sprite.play("Walk")
$Sprite.flip_h = false
elif Input.is_action_pressed("left"):
velocity.x = -speed
$Sprite.play("Walk")
$Sprite.flip_h = true
else:
$Sprite.play("Idle")
velocity.y = velocity.y + gravity
if Input.is_action_just_pressed("Jump") and is_on_floor():
velocity.y = jump
$Sprite.play("Jump")
if not is_on_floor() and velocity.y < -200:
$Sprite.play("Fly")
if not is_on_floor() and velocity.y >= -200 and velocity.y <= 0:
$Sprite.play("Fall")
if not is_on_floor() and velocity.y > 0:
$Sprite.play("Fall1")
if not is_on_floor() and velocity.y > 100:
$Sprite.play("Fall2")
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0,0.2)
I tried using a state but it said tere was an error, the delta wasn’t declared on the scope or something
Adrian Monky | 2021-08-01 12:36
maybe… use a animated sprite and not a normal sprite 
Oh the name is sprite but it is an animated one. Forgot to change it
Adrian Monky | 2021-08-01 13:00
oh,what is the error ? show me your screen (your game)
if you whant to show an image or a video go to this website : https://wetransfer.com/
With that exact code I sent you the error is: “The identifier “_delta” isn’t declared in the current scope.”
Adrian Monky | 2021-08-01 13:10
the error color is red or yellow ?
It is the color red
Adrian Monky | 2021-08-01 13:14
in which line is the error?
the line 18, where it calls the physics process
Adrian Monky | 2021-08-01 13:17
ok last question,pizza or burger ?
Is it about real food or a code thingie?
Adrian Monky | 2021-08-01 13:22
If it is food i’d go with pizza I think
Adrian Monky | 2021-08-01 13:22
it’s food lol,there is no pizza code or burger code
try this :
extends KinematicBody2D
enum {
WATER,
GAS,
ICE
}
var velocity = Vector2(0,0)
const speed = 300
const gravity = 30
const jump = -700
var state = WATER
func _physics_process(delta):
if Input.is_action_pressed(“right”):
velocity.x = speed
$Sprite.play(“Walk”)
$Sprite.flip_h = false
elif Input.is_action_pressed(“left”):
velocity.x = -speed
$Sprite.play(“Walk”)
$Sprite.flip_h = true
else:
$Sprite.play(“Idle”)
velocity.y = velocity.y + gravity
if Input.is_action_just_pressed("Jump") and is_on_floor():
velocity.y = jump
$Sprite.play("Jump")
if not is_on_floor() and velocity.y < -200:
$Sprite.play("Fly")
if not is_on_floor() and velocity.y >= -200 and velocity.y <= 0:
$Sprite.play("Fall")
if not is_on_floor() and velocity.y > 0:
$Sprite.play("Fall1")
if not is_on_floor() and velocity.y > 100:
$Sprite.play("Fall2")
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0,0.2)
func state(state):
match state:
WATER:
_physics_process(delta)
GAS:
pass
ICE:
pass
It said the same thing: “The identifier “delta” isn’t declared in the current scope.”
Adrian Monky | 2021-08-01 13:33
Fixed it! Dumbass me wrote the state(delta) wrong
Adrian Monky | 2021-08-01 14:20
that what i changed in the script,so that work now ?
It does, thank you!
Adrian Monky | 2021-08-01 19:35