Horizontal movement error (SOLVED)

I’m trying to write some movement for the x axis and this error runs through console: /main/movement.script:18: bad argument #1 to ‘set_position’ (vector3 expected, got number)
stack traceback:
[C]: in function ‘set_position’

local acceleration = vmath.vector3()
	self.acceleration = self.input.x * 200

	local dv = acceleration * dt
	local v0 = self.velocity
	self.velocity = self.velocity + dv
	local dx = (v0 + self.velocity) * dt * 0.5

	local p = vmath.vector3()
	self.p = go.get_position()
	go.set_position (p.x + dx)

	self.velocity = v1
	self.input = vmath.vector3

end

I’m currently building a game from the ground up but am currently stuck here

Well, that call to go.set_position expects s vector3 but you are passing in a number (p.x + dx). Do p.x = p.x + dx first and then pass in p.

3 Likes