So, I’m fairly new to this engine, and have been relying on some of the tutorials to work on some things… Yet, I’ve made a player, which works perfectly fine except for the collisions… Does anyone know why?
Scene Directory
:Player Code:
local gravity = -1000
local jump_takeoff_speed = 900
function init(self)
self.vel = vmath.vector3()
msg.post(".", "acquire_input_focus")
end
function update(self, dt)
local pos = go.get_position()
pos = pos + self.vel * dt
go.set_position(pos)
self.vel.x = 0
self.vel.y = 0
end
local function jump(self)
if self.ground_contact then
self.vel.y = jump_takeoff_speed
end
end
local function abort_jump(self)
if self.vel.y > 0 then
self.vel.y = self.velocity.y * 0.5
end
end
function on_input(self, action_id, action)
if action_id == hash("left") then
self.vel.x = -150
elseif action_id == hash("right") then
self.vel.x = 150
elseif action_id == hash("jump") then
self.vel.y = jump_takeoff_speed
--if self.vel.y > 0 then
-- self.vel.y = self.velocity.y * 0.5
--end
end
end
P.S: I am aware that the player doesn’t fall, but I do have a wall in my scene that should make the player collide with it…