Acceleration now directionless. It doesn't work yet but at least it doesn't crash.
This commit is contained in:
parent
b49b1d67d2
commit
d7d612db72
|
|
@ -5,8 +5,13 @@ extends Reference
|
|||
|
||||
export(PoolVector2Array) var _speed_start = PoolVector2Array([Vector2(0,0),Vector2(0,0),Vector2(0,0)])
|
||||
export(PoolVector2Array) var _speed_end = PoolVector2Array([Vector2(0,0),Vector2(0,0),Vector2(0,0)])
|
||||
export(PoolVector2Array) var _acceleration = PoolVector2Array([Vector2(0,0),Vector2(0,0),Vector2(0,0)])
|
||||
|
||||
## MP accelleration is reflective of minimum maximum and adjusted accel
|
||||
## It can be accessed directly now, doesn't need the direction
|
||||
export(Vector2) var _acceleration = Vector2(0,0)
|
||||
const BASE_ACCELERATION = 0
|
||||
const MAX_ACCELERATION = 1
|
||||
const MIN_ACCELERATION = 2 # or -1
|
||||
|
||||
## Vector based ones for x and y
|
||||
#export var base_move_speed :Vector2
|
||||
|
|
@ -43,11 +48,25 @@ func get_speed_end(direction :int) -> Vector2:
|
|||
func set_speed_end(direction :int, value :Vector2) -> void:
|
||||
_speed_end[direction] = value
|
||||
|
||||
func get_acceleration(direction :int) -> Vector2:
|
||||
return _acceleration[direction]
|
||||
func get_acceleration() -> Vector2:
|
||||
return _acceleration
|
||||
|
||||
func set_acceleration(direction :int, value :Vector2) -> void:
|
||||
_acceleration[direction] = value
|
||||
## Sort of the conditional clamp of acceleration parameters
|
||||
func set_acceleration(value :Vector2, min_value :Vector2, max_value :Vector2) -> void:
|
||||
var adjusted_accel = value
|
||||
if adjusted_accel.x < min_value.x:
|
||||
adjusted_accel.x = min_value.x
|
||||
if adjusted_accel.y < min_value.y:
|
||||
adjusted_accel.y = min_value.y
|
||||
|
||||
if max_value.x != 0:
|
||||
if adjusted_accel.x > max_value.x:
|
||||
adjusted_accel.x = max_value.x
|
||||
if max_value.y != 0:
|
||||
if adjusted_accel.y > max_value.y:
|
||||
adjusted_accel.y = max_value.y
|
||||
|
||||
_acceleration = adjusted_accel
|
||||
|
||||
|
||||
func modify(_movement_parameters :MovementParameters):
|
||||
|
|
@ -63,6 +82,24 @@ func apply_multiple_modifiers( _modifiers: Array, _movement_direction :Vector2):
|
|||
|
||||
func apply_state_modifier(_modifier :StateModifierMovement, _movement_direction :Vector2):
|
||||
#_modifier.direction == _modifier.APPLIED_DIRECTIONS.LEFT_OR_UP
|
||||
## Accel processing is the same regardless of direction now
|
||||
set_acceleration( ( _acceleration + _modifier.acceleration),
|
||||
_modifier.min_acceleration,
|
||||
_modifier.max_acceleration )
|
||||
# var adjusted_accel = acceleration[BASE_ACCELERATION] + _modifier.acceleration
|
||||
# if adjusted_accel.x < _modifier.min_acceleration.x:
|
||||
# adjusted_accel.x = _modifier.min_acceleration.x
|
||||
# if adjusted_accel.y < _modifier.min_acceleration.y:
|
||||
# adjusted_accel.y = _modifier.min_acceleration.y
|
||||
#
|
||||
# if adjusted_accel.max_acceleration.x != 0:
|
||||
# if adjusted_accel.x > _modifier.max_acceleration.x:
|
||||
# adjusted_accel.x = _modifier.max_acceleration.x
|
||||
# if adjusted_accel.max_acceleration.y != 0:
|
||||
# if adjusted_accel.y > _modifier.max_acceleration.y:
|
||||
# adjusted_accel.y = _modifier.max_acceleration.y
|
||||
|
||||
|
||||
match _modifier.modifier_type:
|
||||
StateModifierMovement.SUB_TYPE.NEGATIVE_CONSTRAINT:
|
||||
# var adjusted_move_speed = base_move_speed.x + _modifier.horizontal_speed
|
||||
|
|
@ -103,17 +140,18 @@ func apply_state_modifier(_modifier :StateModifierMovement, _movement_direction
|
|||
# else:
|
||||
# base_move_acceleration.x = adjusted_accel
|
||||
|
||||
var accel :Vector2 = get_acceleration(_modifier.direction)
|
||||
var adjusted_accel = get_acceleration(_modifier.direction) + _modifier.acceleration
|
||||
if sign(adjusted_accel.x) != sign(accel.x):
|
||||
accel.x = 0.0
|
||||
else:
|
||||
accel.x = adjusted_accel.x
|
||||
if sign(adjusted_accel.y) != sign(accel.y):
|
||||
accel.y = 0.0
|
||||
else:
|
||||
accel.y = adjusted_accel.y
|
||||
set_acceleration(_modifier.direction, accel)
|
||||
#var accel :Vector2 = get_acceleration(_modifier.direction)
|
||||
#var adjusted_accel = get_acceleration(_modifier.direction) + _modifier.acceleration
|
||||
|
||||
# if sign(adjusted_accel.x) != sign(accel.x):
|
||||
# accel.x = 0.0
|
||||
# else:
|
||||
# accel.x = adjusted_accel.x
|
||||
# if sign(adjusted_accel.y) != sign(accel.y):
|
||||
# accel.y = 0.0
|
||||
# else:
|
||||
# accel.y = adjusted_accel.y
|
||||
# set_acceleration(_modifier.direction, accel)
|
||||
|
||||
if (true): #DEGUG
|
||||
var foo = 2+2
|
||||
|
|
@ -149,10 +187,10 @@ func apply_state_modifier(_modifier :StateModifierMovement, _movement_direction
|
|||
_modifier.direction,
|
||||
(get_speed_end(_modifier.direction) + _modifier.speed_end)
|
||||
)
|
||||
set_acceleration(
|
||||
_modifier.direction,
|
||||
(get_acceleration(_modifier.direction) + _modifier.acceleration)
|
||||
)
|
||||
# set_acceleration(
|
||||
# _modifier.direction,
|
||||
# (get_acceleration(_modifier.direction) + _modifier.acceleration)
|
||||
# )
|
||||
|
||||
if (true): #DEGUG
|
||||
var foo = 2+2
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ const RELATIVE_DIRECTION = 0
|
|||
# Movement Speed in Pixels Per Second
|
||||
export(Vector2) var speed_start
|
||||
export(Vector2) var speed_end = Vector2(0,1000)
|
||||
export(Vector2) var min_acceleration = Vector2(0,0)
|
||||
export(Vector2) var acceleration = Vector2(0,280)
|
||||
export(Vector2) var max_acceleration = Vector2(0,0)
|
||||
export(Vector2) var jerk_factor = Vector2(1,1)
|
||||
#export(Vector2) var speed_start_positive
|
||||
#export(Vector2) var speed_end_positive
|
||||
|
|
@ -76,7 +78,7 @@ func get_movement_parameters() -> MovementParameters:
|
|||
#movement_parameters.speed_start = speed_start
|
||||
movement_parameters.set_speed_end(RELATIVE_DIRECTION, speed_end)
|
||||
#movement_parameters.speed_end = speed_end
|
||||
movement_parameters.set_acceleration(RELATIVE_DIRECTION, acceleration)
|
||||
movement_parameters.set_acceleration(acceleration, min_acceleration, max_acceleration)
|
||||
#movement_parameters.acceleration = acceleration
|
||||
movement_parameters.jerk_factor = jerk_factor
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ export(APPLIED_DIRECTIONS) var direction :float = float(APPLIED_DIRECTIONS.RELAT
|
|||
|
||||
export(Vector2) var speed_start
|
||||
export(Vector2) var speed_end
|
||||
export(Vector2) var acceleration
|
||||
export(Vector2) var min_acceleration = Vector2(0,0)
|
||||
export(Vector2) var acceleration = Vector2(0,0)
|
||||
export(Vector2) var max_acceleration = Vector2(0,0)
|
||||
|
||||
## Movement Modifiers
|
||||
#export var horizontal_speed: float = 0
|
||||
|
|
@ -100,6 +102,14 @@ func merge(_merge_from_modifier: StateModifier):
|
|||
speed_end += _merge_from_modifier.speed_end
|
||||
speed_start += _merge_from_modifier.speed_start
|
||||
acceleration += _merge_from_modifier.acceleration
|
||||
if (_merge_from_modifier.min_acceleration.x < min_acceleration.x):
|
||||
min_acceleration.x = _merge_from_modifier.min_acceleration.x
|
||||
if (_merge_from_modifier.min_acceleration.y < min_acceleration.y):
|
||||
min_acceleration.y = _merge_from_modifier.min_acceleration.y
|
||||
if (_merge_from_modifier.max_acceleration.x > max_acceleration.x):
|
||||
max_acceleration.x = _merge_from_modifier.max_acceleration.x
|
||||
if (_merge_from_modifier.max_acceleration.y > max_acceleration.y):
|
||||
max_acceleration.y = _merge_from_modifier.max_acceleration.y
|
||||
|
||||
# horizontal_speed += _merge_from_modifier.horizontal_speed
|
||||
# horizontal_acceleration += _merge_from_modifier.horizontal_acceleration
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ timeout_seconds = 0.0
|
|||
direction = 0
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 0 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( -250, 1.36422e-12 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
gravity = 0
|
||||
only_grounded = true
|
||||
processing_mode = 0
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ timeout_seconds = 2.0
|
|||
name = "hurt"
|
||||
speed_start = Vector2( 20, 1.36422e-12 )
|
||||
speed_end = Vector2( 20, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 20.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "attack_punch"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "attack_shoot"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "attack_sword"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ timeout_seconds = 0.0
|
|||
name = "climb"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 20.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "crouch"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "crouch_move"
|
||||
speed_start = Vector2( 60, 1.36422e-12 )
|
||||
speed_end = Vector2( 60, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 60.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "death"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ timeout_seconds = 1.0
|
|||
name = "enter_right"
|
||||
speed_start = Vector2( 30, 1.36422e-12 )
|
||||
speed_end = Vector2( 30, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 30.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "fall"
|
||||
speed_start = Vector2( 90, 1.36422e-12 )
|
||||
speed_end = Vector2( 90, -1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 90.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "idle"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 300.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "jump"
|
||||
speed_start = Vector2( 90, 200 )
|
||||
speed_end = Vector2( 90, -8 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 90.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "land"
|
||||
speed_start = Vector2( 20, 1.36422e-12 )
|
||||
speed_end = Vector2( 20, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 20.0
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "ledge_climb"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "ledge_grab"
|
||||
speed_start = Vector2( 0, 0 )
|
||||
speed_end = Vector2( 0, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 0, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "move"
|
||||
speed_start = Vector2( 10, 1.36422e-12 )
|
||||
speed_end = Vector2( 90, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 70, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 10.0
|
||||
horizontal_acceleration = 70.0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ timeout_seconds = 0.0
|
|||
name = "roll"
|
||||
speed_start = Vector2( 150, 1.36422e-12 )
|
||||
speed_end = Vector2( 10, 1000 )
|
||||
min_acceleration = Vector2( 0, 0 )
|
||||
acceleration = Vector2( 300, 280 )
|
||||
max_acceleration = Vector2( 0, 0 )
|
||||
jerk_factor = Vector2( 1, 1 )
|
||||
horizontal_speed = 150.0
|
||||
horizontal_acceleration = 1.36422e-12
|
||||
|
|
|
|||
|
|
@ -123,11 +123,7 @@ func calculate_velocity(_delta :float,
|
|||
#calc_acceleration.x = abs(resolve_h_acceleration(movement_parameters, move_direction.x))
|
||||
if sign(move_direction.x) != 0:
|
||||
#calc_acceleration.x = abs(movement_parameters.get_acceleration(0).x)
|
||||
calc_acceleration.x = (
|
||||
movement_parameters.get_acceleration(RELATIVE_DIRECTION).x +
|
||||
movement_parameters.get_acceleration(POSITIVE_DIRECTION).x +
|
||||
movement_parameters.get_acceleration(NEGATIVE_DIRECTION).x
|
||||
)
|
||||
calc_acceleration.x = movement_parameters.get_acceleration().x
|
||||
if calc_acceleration.x < 0:
|
||||
push_warning("Negative Acceleration shouln't happen")
|
||||
calc_acceleration.x = abs(calc_acceleration.x)
|
||||
|
|
@ -135,7 +131,7 @@ func calculate_velocity(_delta :float,
|
|||
|
||||
|
||||
if sign(move_direction.y) != 0:
|
||||
calc_acceleration.y = abs(movement_parameters.get_acceleration(0).y)
|
||||
calc_acceleration.y = movement_parameters.get_acceleration().y
|
||||
|
||||
if debug and movement_parameters.debug_name == 'move':
|
||||
var foo = 2+2
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user