Tutorial Astronaut

This post is for information purposes only.

After having completed the above tutorial, my astronaut would move in any direction using the keys, however, the figure would always remain in the idle default view.

The program compiled with no errors.

Long story short, the tutorial script and the script given at the end of the tutorial do not match.

See partial copy of code pasted into this message.

function update(self, dt)
	
	if vmath.length_sqr(self.dir) > 1 then
		self.dir = vmath.normalize(self.dir)
	end

	local p = go.get_position()
	go.set_position(p + self.dir * speed * dt)

	-- self.dir = vmath.vector3()    < < < < < < This code was not in the code at the end. 
                                                                     < < < < < < After removal, the program runs fine.
	-- animate the astronaut

	local anim = hash("idle")

This post is for information purposes only.
Thanks.

Depends what behaviour you want. Do: self.dir = vmath.vector3(), after using it to set the correct animation, otherwise the astronaut will keep moving after key release.

What do you mean by this? The tutorial is available on GitHub, and from what I can tell the complete script at the end looks ok:

Where did you see an incorrect version of the script?

1 Like

In my download I see the problem in:
Readme.md - function update(self, dt)

Thanks

I don’t see the problem? Can you provide me with which line number in README.md:

I’m unable to locate the line now. It looks as if this has been my fault, for which I apologize.

Thanks.

1 Like