Skip to content

Commit

Permalink
More work on manual and some changes to Player.gd.
Browse files Browse the repository at this point in the history
  • Loading branch information
leiget committed Apr 1, 2018
1 parent 6e3c72f commit 4ad8cd8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 37 deletions.
Binary file modified blends/FPC_Base_Mesh.blend
Binary file not shown.
Binary file modified documents/manual.pdf
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,6 @@ data = SubResource( 28 )

[node name="Player" parent="." index="3" instance=ExtResource( 8 )]

transform = Transform( -0.553702, 0, -0.832715, 0, 1, 0, 0.832715, 0, -0.553702, 0, 0.953212, -6.3412 )
transform = Transform( -0.553702, 0, -0.832715, 0, 1, 0, 0.832715, 0, -0.553702, 11.4035, 0.953212, -3.6104 )


44 changes: 39 additions & 5 deletions scenes/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Roughness" ]

[sub_resource type="CapsuleShape" id=4]
[sub_resource type="CapsuleShape" id=3]

radius = 0.2
height = 1.4
_sections_unfolded = [ "Resource" ]

[sub_resource type="DynamicFont" id=3]
[sub_resource type="DynamicFont" id=4]

size = 32
use_mipmaps = true
Expand Down Expand Up @@ -122,12 +122,12 @@ lod_max_hysteresis = 0.0
mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = SubResource( 2 )
_sections_unfolded = [ "material" ]
_sections_unfolded = [ "Transform", "material" ]

[node name="Shape_Capsule" type="CollisionShape" parent="." index="1"]

transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )
shape = SubResource( 4 )
shape = SubResource( 3 )
disabled = false
_sections_unfolded = [ "Transform" ]

Expand Down Expand Up @@ -251,7 +251,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 3 )
custom_fonts/font = SubResource( 4 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "-------"
Expand All @@ -261,4 +261,38 @@ max_lines_visible = -1
script = ExtResource( 7 )
_sections_unfolded = [ "Mouse", "Rect", "Visibility", "custom_colors", "custom_fonts" ]

[node name="Intruction_Label" type="Label" parent="Camera2D/DEBUG" index="1"]

anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 993.0
margin_top = 8.0
margin_right = 1272.0
margin_bottom = 194.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_fonts/font = SubResource( 4 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "Controls:
W/S: Forward/Backward
A/D: Left/Right
Mouse movement: Look around.
Space/RMB: Jump
E: Use object when red circle is visible.
F3: Show/hide debug text and these instructions.
F4: Toggle fullscreen.
Esc: Quit program."
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
script = ExtResource( 7 )
_sections_unfolded = [ "Mouse", "Rect", "Visibility", "custom_colors", "custom_fonts" ]


58 changes: 27 additions & 31 deletions scripts/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var CamInterpo_Length_Secs_Multiplicand = 125.0
# SLOPE SPEED #
# Amount to let slopes affect gravity of the player character, and therefore speed movement speed when walking up them.
# DEFAULT: 0.2
var Slope_EffectMultiplier_ClimbingUp = 0.2
var Slope_EffectMultiplier_ClimbingUp = 0.3
# Amount to let slopes affect gravity of the player character, and therefore speed movement speed when walking down them.
# DEFAULT: 1.5
var Slope_EffectMultiplier_ClimbingDown = 1.5
Expand Down Expand Up @@ -370,7 +370,7 @@ func InterpolateCamera(Prev_Pos_Local_Y, Time_Current, Time_Delta):
# Turn off the camera interpolation.
CamInterpo_DoInterpolation = false
# Return 0 for success.
return 0
return 0.0

########################
# Step_Player_Up(void) #
Expand Down Expand Up @@ -592,7 +592,7 @@ func Slope_AffectSpeed():
# being pulled down so much.

# Setup the X and Z axis of the floor normal as a 2D vector for calculations.
Slope_FloorNor2D = Vector2(get_slide_collision(Slide).normal.x, get_slide_collision(Slide).normal.z)
Slope_FloorNor2D = Vector2(get_slide_collision(Slide).normal.x, get_slide_collision(Slide).normal.z).normalized()

# Setup the temporary velocity vector and normalize the result.
Slope_PlayerVelVec2D = Vector2( (TempMoveVel_FWAndBW.x + TempMoveVel_LeftAndRight.x) , (TempMoveVel_FWAndBW.z + TempMoveVel_LeftAndRight.z) ).normalized()
Expand All @@ -608,10 +608,14 @@ func Slope_AffectSpeed():
else:
# Multiply the slope's dot product by the slope effect multipler, so that the game designer can say how much he wants the slope to affect the player's walking
# velocity.
Slope_DotProduct *= Slope_EffectMultiplier_ClimbingUp
Slope_DotProduct *= -Slope_EffectMultiplier_ClimbingUp

# Finally, set the falling speed multiplier.
Falling_Speed_Multiplier = lerp(Falling_Speed_Multiplier_Default, 1.0, pow( MaxFloorAngleNor_Y / get_slide_collision(Slide).normal.y , 4) * abs(Slope_DotProduct))
Falling_Speed_Multiplier = lerp(
Falling_Speed_Multiplier_Default ,
1.0 ,
pow( acos( get_slide_collision(Slide).normal.y ) / acos( MaxFloorAngleNor_Y ) * Slope_DotProduct, 2.0)
)



Expand All @@ -626,7 +630,7 @@ func _ready():
# Unhandled input is any input that is not handled by the GUI(control) or from _input().
# For instance, pressing space in a textbox won't make your character jump.
#set_process_unhandled_input(true)
set_process_input(true)
set_process_unhandled_input(true)

# Set the physics to be done. This is now the new _fixed_process() from Godot 2.1.
# This is called according to the physics system's framerate. If it is set to 60 (in
Expand All @@ -644,24 +648,15 @@ func _ready():
#First, we must do "move_and_slide()" so that we can get some of our states.
move_and_slide(Vector3(0.0, 0.0, 0.0), FloorNormal, SlopeStopMinVel, MaxSlides, MaxFloorAngleRad)

# Set Player On Floor #
# This makes the character start falling if not placed on a floor.
# If the player is on the floor...
if(is_on_floor()):
# Say that he is not falling.
State_Falling=false
# And that he is one the floor in the variable.
State_OnFloor = true
# Otherwise, he's not on the floor. So...
else:
# Say that he is falling.
State_Falling=true
# And that he is not on the floor.
State_OnFloor = false

# Set if the player is on a wall.
# This is simply to initialize whether the character is on a wall.
# Collision States #
# Set if the player is on a wall, floor, or ceiling.
State_OnFloor = is_on_floor()
State_OnWalls = is_on_wall()
State_OnCeiling = is_on_ceiling()

# Falling State #
# Initialize the player as falling.
State_Falling = true

# If the jump action is not pressed...
if(not Input.is_action_pressed(String_Jump)):
Expand Down Expand Up @@ -696,7 +691,7 @@ func _ready():
# This is for any input not handled elsewhere, like if a control node (a GUI node, like a window or something)
# is currently using the mouse, this function will not run. When the GUI node is gone/minimized/no longer
# there, the input will be handled here.
func _input(event):
func _unhandled_input(event):
#############
# MOUSE #
#############
Expand Down Expand Up @@ -789,7 +784,7 @@ func _physics_process(delta):
# Say that the jump key has not been released.
Jump_Released = false
# Otherwise, if the jump key was released...
elif(not Input.is_action_pressed(String_Jump)):
else:
# Say that the player is not pressing the jump key.
Pressed_Jump = false
# And say that he has released it.
Expand All @@ -810,10 +805,11 @@ func _physics_process(delta):
# Set the step saftey margin according to the player's current speed.
Step_SafetyMargin = Step_SafetyMargin_Dividend / (BaseWalkVelocity / FinalWalkVelocity)

# If the camera isn't currently being interpolated...
if(CamInterpo_CurrentTime_Secs > CamInterpo_Length_Secs):
# Set the camera interpolation length according to the speed of the player.
CamInterpo_Length_Secs = BaseWalkVelocity / (CamInterpo_Length_Secs_Multiplicand * (FinalWalkVelocity / 10.0) )
#############################################
# CAMERA INTERPOLATION LENGTH MODIFIER #
#############################################
# Set the camera interpolation length according to the speed of the player.
CamInterpo_Length_Secs = BaseWalkVelocity / (CamInterpo_Length_Secs_Multiplicand * (FinalWalkVelocity / 10.0) )

#############################################
# CROSSHAIR: USABLE ITEM #
Expand Down Expand Up @@ -852,7 +848,7 @@ func _physics_process(delta):
# Use the function of the object intersected.
Ray_Result.collider.get_parent().UseFunction()
#NO USE FUNCTION#
# Otherwise, if there is not...
# Otherwise, if there is no use function...
else:
# Hide the red circle.
Node_Crosshair_Useable.visible=false
Expand All @@ -861,7 +857,7 @@ func _physics_process(delta):
# Else, if the ray hit nothing...
else:
# Hide the red circle.
Node_Crosshair_Useable.visible=false
Node_Crosshair_Useable.visible = false
# Then reset the ray intersections position.
Use_Ray_IntersectPos = Vector3(0,0,0)

Expand Down

0 comments on commit 4ad8cd8

Please sign in to comment.