How To Make Character Movement (With Smooth Transitions) | RanGE

How To Make Character Movement (With Smooth Transitions) | RanGE

Character Movement Tutorial: From Idle to Running Animation

Introduction to Character Movement

  • This tutorial focuses on transitioning a character from an idle state to a running animation using the WASD keys for movement. The character will also smoothly return to the idle position when movement stops.

Preparing Animations

  • Users must select their character armature and ensure they have a complete run animation ready, including transitions from idle to run and back. This video does not cover how to create these animations but offers free downloadable resources.
  • A free run animation, along with other animations and the base character model, is available via links in the description box of social media platforms.

Structuring Animations

  • If users have created their own run animation, it should be divided into three parts:
  • Idle to Run (takeoff phase)
  • Run Loop (main running phase)
  • Run to Idle (returning phase)

Each section must start at frame zero.

Keyframe Management

  • Keyframes can be manipulated similarly to objects; users can select them individually or as a group using various selection methods (A for all, box/circle select). Moving keyframes involves pressing G and dragging with the mouse.
  • To prevent accidental deletion of animations that are not currently assigned, pressing F ensures they remain saved even if unused in the project. This practice helps avoid frustration later on.

Setting Up Keyboard Controls

  • In the logic editor, four keyboard sensors are added for each direction (WASD), which trigger corresponding actions for moving forward, left, right, and backward. True triggering should be enabled for all sensors.
  • These sensors connect to a Python controller that activates the idle-to-run animation and sets up state management for running actions within the game environment. The end frame of this transition is noted as crucial for programming purposes.

Implementing State Management

  • A state actuator is introduced alongside action actuators linked with keyboard inputs; this allows seamless transitions between states based on user input while ensuring both armature and controller operate in sync during movement phases.

Script Integration

  • Users need to define sensor names in scripts under an "inputs" section while creating definitions for action actuators related to animations and states within their code structure.

This organization simplifies coding by reducing redundancy through combined statements instead of individual blocks per key press event.

Transitioning Between States

  • When any WASD key is pressed, both action actuators activate simultaneously; this includes sending messages between controllers so that both armature and character controller enter running states effectively without lag or disconnection during gameplay sessions.

The use of message lines facilitates communication between different components within Blender Game Engine modules efficiently without confusion over object references or commands sent across systems involved in gameplay mechanics like motion control or state changes triggered by player input events such as keystrokes detected through keyboard sensors set up earlier on during initialization stages outlined previously throughout this tutorial series thus far!

Finalizing Animation Playback Logic

  • After setting up initial controls successfully allowing characters move around freely according user commands issued via WASD keys pressed down continuously until released again afterward returning back original positions automatically once no longer active anymore either way depending circumstances surrounding current situation unfolding dynamically real-time basis throughout entire duration playthrough experience overall! Thus ensuring smooth transitions occur naturally whenever necessary without interruption whatsoever hindering progress made towards achieving desired outcomes expected from players engaging fully immersive environments designed specifically cater needs preferences expressed openly throughout course journey taken together collaboratively working hand-in-hand toward common goals shared mutually amongst everyone involved collectively striving achieve greatness together ultimately culminating success stories told generations future ahead waiting patiently discover what lies beyond horizon just waiting unfold before eyes eager witness magic happen right here now today!

Character Movement System Implementation

Setting Up the Run to Idle Animation

  • The run to idle animation is integrated into state one of the character controller, requiring messages to be sent for movement during this transition.
  • A new section for the run to idle animation is created in the definitions, mirroring the setup used for transitioning from idle to run.
  • The character's movement slows down gradually through specific frames, with a quick scurry followed by longer steps until reaching an idle position.

Configuring Character Controller Logic

  • Messages are established for different motion phases (run to idle motion one, two, and three), which will be linked to the character controller's logic editor.
  • The workflow involves adding message sensors for each motion phase and connecting them with corresponding motion actuators while applying specific values for smooth transitions.

Directional Control Setup

  • To enable directional control using WASD keys, an empty object is added in front of the character and positioned accurately within the grid.
  • Multiple empties are created around the character (front, left, right, back), including diagonal positions by rotating duplicates at 45° angles.

Parenting Empties and Tracking Directions

  • All empties are parented to a camera look empty so that they maintain their relative positions regardless of camera rotation.
  • Each empty is named according to its direction (e.g., face front, face left), facilitating easy reference when programming tracking behavior in response to key presses.

Implementing Tracking Logic in Code

  • In the logic editor of the character controller's running state, a message sensor and actuator are prepared for tracking objects based on player input.
  • A new section called "objects" is added in code definitions allowing direct access to track actuators within the character controller upon receiving messages.

Coding Movement Directions

  • If any WASD keys are pressed, a message activates tracking towards designated empties based on direction; this includes handling both primary directions and diagonals effectively.
  • Similar coding structures are applied across all eight possible movement directions ensuring smooth transitions as players navigate using WASD keys.

Finalizing Character Movement System

  • Upon testing with WASD inputs, characters now correctly face their intended direction relative to camera perspective due to proper parenting of empties.
  • The tutorial concludes after seven hours of recording time spent developing this comprehensive character movement system.
Video description

How to make your character run (with smooth animation transitions) in the RanGE game engine. 00:00 Intro 01:06 Seperating the Run Animation 02:27 Idle to Run Transition 06:25 Run Animation 07:51 Run To Idle Transition 10:12 Smoothening the Transtions 10:47 Resetting the Animations 13:15 Adding the Movement 16:20 Making the Camera follow the Player 17:32 Configure the Shadow Box to follow the Player 18:09 Adding the Movement 19:59 Running in 8 directions (with WASD) 25:32 Outro Download Character Model & Armature (+ animations): https://drive.google.com/file/d/1RwgpPJlZPcDrv9OCChIxLf1F_aRqPs18/view?usp=drive_link Patreon: https://patreon.com/StephenDdungu Join my community discord server: https://discord.com/invite/Fg77ETueNq This is the 7th video in the RanGE Foundation Course. See the complete tutorial list here: https://youtube.com/playlist?list=PLJuvPCDwGvcmp_pay5Zcg7QBy0zI2CQon&si=tnbygLG-2hvQCL4l If you found this video helpful, don't forget to like & subscribe. Thanks! Stephen ------------------------------- #rangeengine #logicbricks #python #b3d #gamelogic #upbge