From 16447163065275e289938851693fd67e432d0478 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 22 Jan 2018 21:37:21 -0500 Subject: [PATCH] Fix player bouncing unnaturally on objective At this point I've pretty much deleted all of Calinou's code. Oh well, it DID get me started. --- scripts/player.gd | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/scripts/player.gd b/scripts/player.gd index 96a8d82..ae99045 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,5 +1,3 @@ -# Copyright (c) 2015 Calinou -# This source code form is governed by the MIT license. # Original: https://raw.githubusercontent.com/Calinou/fps-test/master/scripts/player.gd extends RigidBody @@ -93,25 +91,7 @@ func control_player(state): var floor_velocity = Vector3() var object = ray.get_collider() - if object is RigidBody or object is StaticBody: - var point = ray.get_collision_point() - object.get_translation() - var floor_angular_vel = Vector3() - if object is RigidBody: - floor_velocity = object.get_linear_velocity() - floor_angular_vel = object.get_angular_velocity() - elif object is StaticBody: - floor_velocity = object.get_constant_linear_velocity() - floor_angular_vel = object.get_constant_angular_velocity() - # Surely there should be a function to convert Euler angles to a 3x3 matrix - var tf = Basis(Vector3(1, 0, 0), floor_angular_vel.x) - tf = tf.rotated(Vector3(0, 1, 0), floor_angular_vel.y) - tf = tf.rotated(Vector3(0, 0, 1), floor_angular_vel.z) - floor_velocity += tf.xform_inv(point) - point - yaw = fmod(yaw + rad2deg(floor_angular_vel.y) * state.get_step(), 360) - get_node("Yaw").set_rotation(Vector3(0, deg2rad(yaw), 0)) - - var diff = floor_velocity + direction * walk_speed - state.apply_impulse(Vector3(), diff * get_mass()) + state.apply_impulse(Vector3(), direction * walk_speed * get_mass()) var lin_v = state.get_linear_velocity() lin_v.x *= floor_friction lin_v.z *= floor_friction