#Sprite3d Player Help and Setup

1 messages · Page 1 of 1 (latest)

surreal phoenix
#

Try to follow this tutorial, https://youtu.be/cnXmwMpn4pw?si=zy19ztFUN--pb7kc
do everything but in the 3D variant, AnimationPlayer/AnimationTree setup should be same.

Using Animation Player, Animation Tree, and some basic Gdscript we can make a CharacterBody2D move in 8 directions for Idle and Move when meshed with appropriate 8 directional art work.

Project Download
Ko-fi ➣ https://ko-fi.com/post/PROJECT-8-Directional-Animation-Setup-for-2D-God-F1F314J5UX
Patreon ➣ https://www.patreon.com/posts/11371147...

▶ Play video
robust plover
#

io got to about 13:58 in the video and got stuck at the point where i had did this as it said, but the thiny said to use character body 3d because it cant extend from 2d because its a character body 3d node

#

but doing that tells me this

robust plover
#

so like, where do i go from here of course

surreal phoenix
# robust plover but doing that tells me this

since we're in 3d world we will always need Vector3 to do position/transform(scale/rotate) stuff but we want our character to move like the 2d world, so to sort of simulate the up/down effect, you can use input_vector's x and y axes values as x and z

var input_vector3 = Vector3(input_vector.x, 0, input_vector.z);
velocity = input_vector3 * speed;
# rest of everything
robust plover
surreal phoenix
robust plover
robust plover
#

yes, in the play window i do

#

though now that i think of it, i guess it would be hard to tell if the character is moving in a 3d axis from a sprite in the void than if it were a 2d plane

surreal phoenix
robust plover
#

did it like this, and still the same result

#

honestly at this point, trying to just use built in character controllers and just sticking to regular 3d models might be a better bet for me

#

trying to wrap my head around alot of this stuff when i don't really have a basic understanding of things and then trying to do something that doesnt have direct tutorials is probably a bit too much of an ask when i hae to go out of my way to ask others for help

surreal phoenix
robust plover
#

@export var animation_tree : AnimationTree
var input : Vector3
var playback : AnimationNodeStateMachinePlayback

func _ready():
    playback = animation_tree["parameters/playback"]

const SPEED = 5.0
const JUMP_VELOCITY = 4.5


func _physics_process(delta):
    # Add the gravity.
    if not is_on_floor():
        velocity += get_gravity() * delta

    # Handle jump.
    if Input.is_action_just_pressed("ui_accept") and is_on_floor():
        velocity.y = JUMP_VELOCITY

    # Get the input direction and handle the movement/deceleration.
    # As good practice, you should replace UI actions with custom gameplay actions.
    var input_dir = Input.get_vector("Left", "Right", "Back", "Front")
    var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
    if direction:
        velocity.x = direction.x * SPEED
        velocity.z = direction.z * SPEED
    else:
        velocity.x = move_toward(velocity.x, 0, SPEED)
        velocity.z = move_toward(velocity.z, 0, SPEED)
    
    $AnimationTree.set("parameters/conditions/idle", input_dir == Vector3.ZERO && is_on_floor())
    $AnimationTree.set("parameters/conditions/walk", input_dir != Vector3.ZERO && is_on_floor())
    
    move_and_slide()
    select_animation()
    update_animation_parameters()

func select_animation():
    if velocity == Vector3.ZERO:
        playback.travel("Idle")
    else:
        playback.travel("Walk")

func update_animation_parameters(): 
    if input == Vector3.ZERO:
        return
        
    animation_tree["parameters/Idle/blend_position"] = input
    animation_tree["parameters/Walk/blend_position"] = input
#

i ended up doing all of this while watching a 3d tutorial and the 2d one you sent at the same time and trying to mix the two and fix things on the way, but now its just doing this infinitely