Sun. Dec 22nd, 2024
This entry is part 60 of 185 in the series Developer Blog

Working on the Godot RPG tutorial on outube.

Make an Action RPG in Godot 3.2 (P1)

Lesson 1 – Player movement

	Lesson 1
	Basic Keyboard action control - no diagonals	
	if Input.is_action_pressed("ui_right"):
		print ("Pressed Right Arrow Key")
		velocity.x = 4
	elif Input.is_action_pressed("ui_left"):
		print ("Pressed Left Arrow Key")
		velocity.x = -4
	else:
		print ("No Left or Right Key Pressed")
		velocity.x = 0	
		
	if Input.is_action_pressed("ui_up"):
		print ("Pressed Up Arrow Key")
		velocity.y = -4
	elif Input.is_action_pressed("ui_down"):
		print ("Pressed Down Arrow Key")
		velocity.y = 4
	else:
		print ("No Up or Down Key Pressed")
		velocity.y = 0
		
	move_and_collide(velocity * delta)

Make an Action RPG in Godot 3.2 (P2)

Make an Action RPG in Godot 3.2 (P3)

Make an Action RPG in Godot 3.2 (P4)

Lesson 4 – Animation Player

	Lesson 4 if using animpationPlayer
	if input_vector != Vector2.ZERO:
		if input_vector.x >0:
			animationPlayer.play("RunRight")
		elif input_vector.x <0:
			animationPlayer.play("RunLeft")
		else: 
			animationPlayer.play("IdleDown")	
		
		if input_vector.y >0:
			animationPlayer.play("RunDown")
		elif input_vector.y <0:
			animationPlayer.play("RunUp")	
		else: 
			animationPlayer.play("IdleDown")	
		velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
		print(velocity)
		
	else:
		if input_vector.x >0:
			animationPlayer.play("IdleRight")
		elif input_vector.x <0:
			animationPlayer.play("IdleLeft")
		else:
			animationPlayer.play("IdleDown")
			
		if input_vector.y >0:
			animationPlayer.play("IdleDown")
		elif input_vector.y >0:
			animationPlayer.play("IdleUp")	
		else:
		animationPlayer.play("IdleDown")	 
	velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
		
	velocity = velocity.clamped(MAX_SPEED)
	velocity = move_and_slide(velocity)

Make an Action RPG in Godot 3.2 (P5)

Lesson 5 – part 2

onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
	#Lesson 5 - Using AnimationTree
	if input_vector != Vector2.ZERO:
		animationTree.set("parameters/Idle/blend_position", input_vector)
		animationTree.set("parameters/Run/blend_position", input_vector)
		animationState.travel("Run")
		velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
		print(velocity)
	else:
		animationState.travel("Idle")
		velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
		
	velocity = velocity.clamped(MAX_SPEED)
	velocity = move_and_slide(velocity)
Series Navigation<< Dev Log – Ice Hockey Themed Connect 3 – Jun 5th – Part 28Dev Log – 1/30/2020 >>
Kids Hide Away