The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I want my weapon sprite to have a movement like this. I tried to do it but i didn't make it. How can i do it?

btw here is my gun code:

extends Control

onready var anim_player = $AnimationPlayer

var can_shoot = true

# Weapon sway
var MoveAmount = .5
var MoveSpeed = 20

var _origin = rect_position

func _ready():"idle")

func _physics_process(delta):
    if Input.is_action_pressed("shoot") and can_shoot:"shoot")

    var mouse_position = get_viewport().get_mouse_position()

    var moveOnX = mouse_position.x * MoveAmount
    var moveOnY = mouse_position.y * MoveAmount

    var newPos = Vector2(moveOnX, _origin.y + moveOnY)

    _origin = lerp(_origin, newPos, MoveSpeed)
Godot version 3.5
in Engine by (51 points)

What effect are you talking about? A weapon (and the appendage to which it is attached) being affected by the motion of the player's movements? Maybe this video from Garbaj would help?

it workedddddddddd thxxxxx!!!!!!!!!!!!!!!!!!!!!!!11!1

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.