Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | debarstard |
I’m a Artist defo not a coder so need some help with the code it does not compile could some one knowledgeable help me out
extends KinematicBody2D
const MOVE_SPEED = 500
#Jump
export var fall_gravity_scale := 150.0
export var low_jump_gravity_scale := 100.0
export var jump_power := 500.0
var jump_released = false
#Physics
var velocity = Vector2()
var earth_gravity = 9.807 # m/s^2
export var gravity_scale := 100.0
var on_floor = false
func _physics_process(delta):
var move_dir = 0
if Input.is_action_pressed(“rightmove”):
move_dir += 1
if Input.is_action_pressed(“leftmove”):
move_dir -= 1
move_and_slide(Vector2(move_dir * MOVE_SPEED, y_velocity), Vector2(0, -1))
if Input.is_action_just_released(“jump”):
jump_released = true
#Applying gravity to player
velocity += Vector2.DOWN * earth_gravity * gravity_scale * delta
#Jump Physics
if velocity.y > 0: #Player is falling
#Falling action is faster than jumping action | Like in mario
#On falling we apply a second gravity to the player
#We apply ((gravity_scale + fall_gravity_scale) * earth_gravity) gravity on the player
velocity += Vector2.DOWN * earth_gravity * fall_gravity_scale * delta
elif velocity.y < 0 && jump_released: #Player is jumping
#Jump Height depends on how long you will hold key
#If we release the jump before reaching the max height
#We apply ((gravity_scale + low_jump_gravity_scale) * earth_gravity) gravity on the player
#It result on a lower jump
velocity += Vector2.DOWN * earth_gravity * low_jump_gravity_scale * delta
if on_floor:
if Input.is_action_just_pressed(“jump”):
velocity = Vector2.UP * jump_power #Normal Jump action
jump_released = false
velocity = move_and_slide(velocity, Vector2.UP)
if is_on_floor(): on_floor = true
else: on_floor = false
could you please put it more friendly like this? There is a button with brackets at the top of the editor…
extends RigidBody2D
export (int) var kick_force = 300
onready var arrow_kick = $arrow_kick
func _ready():
GLOBAL.kicker = self
var physics_linear_velocity
func _integrate_forces(state):
if physics_linear_velocity:
linear_velocity = physics_linear_velocity
physics_linear_velocity = null
func kick (direction, kick_scale):
print(kick_scale)
physics_linear_velocity = direction.normalized() * kick_force * kick_scale
func point_at(direction):
arrow_kick.point_at(direction)
fershopls | 2019-11-26 18:24