This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

hi guy's, im trying to make a firing system in gdscript following the tutorial on this website:

but theres an error in one

func process(delta):
andcollide(Vector3.DOWN * fallingSpeed * delta)
moveandcollide(transform.basis.x * moveSpeed * delta)
if Input.isactionpressed("uileft"):
rotate(Vector3.UP, +rotatingSpeed * delta)
rotate(Vector3.UP, -rotatingSpeed * delta)

if Input.is_action_just_pressed("ui_accept"):
var b = Bullet.instance()                 <------ error
b.transform = $Cannon/Muzzle.global_transform
b.velocity = -b.transform.basis.z * b.muzzle_velocity


this script is in the player

Godot version 3.3
in Engine by (224 points)

What does the error message say?

2 Answers

+1 vote

your code should be like this

    if Input.is_action_just_pressed("ui_accept"):
        var b = Bullet.instance() 
        b.transform = $Cannon/Muzzle.global_transform
        b.velocity = -b.transform.basis.z * b.muzzle_velocity

because the if statement always go like this

if some_condition:
    code goes here
by (942 points)
edited by
0 votes

ok ,thanks .
it works

by (224 points)
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.