• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Godot Shooter] #2: Create Characters & Shoot Bullets

AnonyViet by AnonyViet
February 1, 2023
in Tips
0

In this article, I will guide you to create characters for Shooter game with Godot.

Join the channel Telegram of the AnonyViet 👉 Link 👈

CREATE CHARACTERS

First of all, download the art.

Links: https://opengameart.org/content/animated-top-down-survivor-player

AnimatedSprite

First you delete the Sprite and then add yourself the AnimatedSprite node.[Godot Shooter]  #2: Create Characters & Shoot Bullets 25

Then Create New Frame

[Godot Shooter]  #2: Create Characters & Shoot Bullets 26

Then add me

3 animations are : idle – move – shoot

Handgun – Rifle – Shotgun you can get inside

[Godot Shooter]  #2: Create Characters & Shoot Bullets 27

Drag them all into 3

[Godot Shooter]  #2: Character Creation & Shooting 28

Set CollisionShape2D again.

[Godot Shooter]  #2: Create Characters & Shoot Bullets 29

Code:

Next is the code. We will test if the player moves, it will run the animation move and stand still and run the animation idle, if it shoots, it will run the animation shoot.

[Godot Shooter]  #2: Create Characters & Shoot 30 . Bullets

Next because this is a shooter we have to let the character rotate in the direction of the mouse, then we have the command: look_at(get_global_mouse_position())

[Godot Shooter]  #2: Create Characters & Shoot Bullets 31

Next set the camera, let’s look at it easily:

Add the camera2D node in Zoom to make it easier to see guys.

[Godot Shooter]  #2: Character Creation & Shooting 32

WOMAN SUNSHINE

Next we will create bullets to shoot piu piu

Download link: https://drive.google.com/file/d/1fr4xNtR-s5qS49G5N98in3oTVlVJyxAN/view?usp=sharing

Please download.

Done then create a new sense

Original button is Area 2D to check when bullet collides

CollisionShape2D

Sprite

[Godot Shooter]  #2: Character Creation & Shooting 33

You drag the bullet image into the Sprite

Then set collisionShape2D too

Then change the name to Bullet

[Godot Shooter]  #2: Character Creation & Shooting 34

Create New Script

[Godot Shooter]  #2: Create Characters & Shoot Bullets 35

Here I will add a function so that the bullet can spawn somewhere you want and Damage (damage)

func start_at(pos, dir):
position = pos
rotation = dir
velocity = Vector2(speed, 0).rotated(dir)

position =pos : means the position of the bullet will reject the pos

rotation = rotation of the bullet

[Godot Shooter]  #2: Character Creation & Shooting 36

Next, we will create a function to assign speed to the bullet so that it can fly

func _physics_process(delta):
position += velocity * delta

[Godot Shooter]  #2: Character Creation & Shooting 37

Oh, remember to turn 2 buttons Sprite and Collishape Move horizontally if you don’t want it to shoot vertically

Then next we have to check if the bullet leaves the screen, it will self-destruct so that it can’t accumulate again causing lag.

Then you add the button VisibilityNotifier2D then adjust the dog is fine. Then connect the signal screen_exit (quit screen)

[Godot Shooter]  #2: Character Creation & Shooting 38

[Godot Shooter]  #2: Create Characters & Shoot Bullets 39

Then in that sentence we add the command: queue_free()

[Godot Shooter]  #2: Character Creation & Shooting 40 . Bullets

Then next we’ll shoot it.

Before that you need to have the bullet’s sence to be able to add it and use onready, it will be loaded when running.

[Godot Shooter]  #2: Character Creation & Shooting 41

Then check if key is pressed F it will shoot

[Godot Shooter]  #2: Character Creation & Shooting 42

get_parent().add_child(b): means it will take the parents and then add_child ie add the bullet button if there is a video, I will illustrate it easier.

b.start_at(global_position,rotation) : global_position = position of the character, rotation is the angle of rotation.

When shooting you will see it appear in the middle of the player, we need to adjust it outside the gun. Then do the following.

You add a Position2D button and then drag it to the place where you want the bullet to appear

[Godot Shooter]  #2: Character Creation & Shooting 43

Next is simple, you just need to add $Position2D before the global_position to spawn in the above place.

[Godot Shooter]  #2: Character Creation & Shooting 44

And if you run it, you will have a situation like the picture

[Godot Shooter] #2: Create Characters & Shoot Bullets

And the next post will have a fix

Code Player:

extends KinematicBody2D




export var speed = 200




onready var bullet = preload("res://Canh/Bulet.tscn")

func _physics_process(delta):

look_at(get_global_mouse_position())

laydau_nhapvao(delta)




func laydau_nhapvao(delta):

var vector_dauvao = Vector2.ZERO

vector_dauvao.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")

vector_dauvao.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")

vector_dauvao = vector_dauvao.normalized()

if vector_dauvao != Vector2.ZERO:

$AnimatedSprite.play("move")

else:

$AnimatedSprite.play("idle")

var dichuyen = vector_dauvao * speed * delta

if Input.is_key_pressed(KEY_F):

shoot()

dichuyen = move_and_collide(dichuyen)

func shoot():

var b = bullet.instance()

get_parent().add_child(b)

b.start_at($Position2D.global_position,rotation)

The article achieved: 5/5 – (100 votes)

Tags: bulletscharacterscreateGodotShootShooter
Previous Post

How to Backup Password on Iphone with 4uKey Password Manager

Next Post

Diverse Crypter v4 FUD Full – Tool to help bypass Antivirus

AnonyViet

AnonyViet

Related Posts

5+ prompts to create sparkling Christmas photos for mothers and babies at home
Tips

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster
Tips

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas
Tips

Share Snowfall Code for Website to celebrate Christmas

December 16, 2025
How to build web applications in just minutes with Youware
Tips

How to build web applications in just minutes with Youware

December 15, 2025
5 Free Adobe Illustrator Alternatives on Linux
Tips

5 Free Adobe Illustrator Alternatives on Linux

December 15, 2025
Review of Chongluadao utility – HieuPC’s new anti-fraud utility
Tips

Review of Chongluadao utility – HieuPC’s new anti-fraud utility

December 14, 2025
Next Post
Diverse Crypter v4 FUD Full – Tool to help bypass Antivirus

Diverse Crypter v4 FUD Full - Tool to help bypass Antivirus

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas

Share Snowfall Code for Website to celebrate Christmas

December 16, 2025
How to build web applications in just minutes with Youware

How to build web applications in just minutes with Youware

December 15, 2025
5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas

Share Snowfall Code for Website to celebrate Christmas

December 16, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

trang chủ f168 nhà cái 78win https://www.qq8827.com/ https://go99.ae.org/ https://nohu90.bid/

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

trang chủ f168 nhà cái 78win https://www.qq8827.com/ https://go99.ae.org/ https://nohu90.bid/

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply