In the midst of a project where a person (gltf object) walks based on key presses, I have successfully updated the object position accordingly.
However, I'm encountering difficulty in rotating the object when the left/right keys are pressed and ensuring that the object continues to walk in that direction.
I have included the code for reference below:
import { OrbitControls } from '../assets/js/OrbitControls.js';
import { GLTFLoader } from '../assets/js/GLTFLoader.js';
import { OBJLoader } from '../assets/js/OBJLoader.js';
// Various functions and initializations
function init(){
// Code block for initializing the scene, camera, lights, loaders, and objects
}
function loadDoor(){
// Loading the door object with necessary transformations
};
function loadMan(){
// Loading the animated man object with animation playback
}
function getAlternateTiles() {
// Generating alternate tiles pattern on the floor
}
function getFloorMaterialByImage() {
// Applying image texture to the floor material
}
// Animation loop
function animate() {
// Calling render function and updating the walking man
}
function updateMan(){
// Updating the position and rotation of the walking man based on keyboard input
}
function render()
{
// Rendering the scene with camera view
}
A link showcasing the animation used in the project can be found here.
Your assistance with this matter is greatly appreciated. Thank you!