|
|
|
|
Reply From: |
Montasir Raihan |
Hello.
Bit of advise, use the “Code Sample” button to format your code when you post your questions. It’ll make your code much more readable.
However, I don’t see any errors in your code. I’ve tested it on my own Godot engine. The code looks like this.
extends RigidBody2D
var bulletPath = preload("res://Bullet.tscn")
func _physics_process(delta):
if Input.is_action_pressed("Shoot"):
shoot()
func shoot():
var bullet = bulletPath.instance()
print("ok")
get_parent.add_child(bullet)
bullet.position = $Shoot.global_position
Everything works perfectly. Are you getting any errors in the debugger?
And yes. I also need to see your node structure.
Montasir Raihan | 2021-07-23 18:56
Nope. Nothing’s wrong in your script file Gun.gd. Everything’s okay. Can I see the script of Player.gd and the node structure of your Player scene?
Montasir Raihan | 2021-07-24 02:36
sure but have you watch the second video ?
there the code here :
extends KinematicBody2D
const UP = Vector2(0, -1)
var motion = Vector2()
var speed = 200
var mspeed = -200
func _physics_process(delta):
if Input.is_action_pressed(“ui_right”):
motion.x = speed
elif Input.is_action_pressed(“ui_left”):
motion.x = mspeed
elif Input.is_action_pressed(“ui_up”):
motion.y = mspeed
elif Input.is_action_pressed(“ui_down”):
motion.y = speed
else:
motion.x = 0
motion.y = 0
motion = move_and_slide(motion,UP)
pass
if Input.is_action_pressed("Slowmo"):
Engine.time_scale = 0.1
else :
Engine.time_scale = 1
if Input.is_action_pressed("Reset"):
get_tree().reload_current_scene()
and
there
is
the
IMAGE :
WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free
just a question,du you live in london ?
(just a question,du you live in london ?) → No I don’t. Why the question?
And yes I’ve seen your 2nd video. Rick Astley’s song Never Gonna Give You Up. I don’t know why you’ve sent me this link. But I’m trying to solve your problem. I need to focus on that. Soon I’ll give you an answer.
And besides I’ve answered your question '‘Why my game freeze?’. Did you check it?
Montasir Raihan | 2021-07-24 11:03