• 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: Character Creation & Shooting 45 . 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

4 ways to fix bluetooth connectivity on Windows 11
Tips

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
How to know the computer is tracked and processed by Keylogger
Tips

How to know the computer is tracked and processed by Keylogger

August 7, 2025
Opal: Create applications who do not need to write code
Tips

Opal: Create applications who do not need to write code

August 3, 2025
How to activate a new Start menu on Windows 11
Tips

How to activate a new Start menu on Windows 11

July 29, 2025
Intellgpt: AI tool for osint and data science
Tips

Intellgpt: AI tool for osint and data science

July 28, 2025
How to create Google Ai Pro 12 months free with Indian student account
Tips

How to create Google Ai Pro 12 months free with Indian student account

July 27, 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

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
How to install GPT-suns on who do not need the Internet

How to install GPT-suns on who do not need the Internet

August 12, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 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

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

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

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

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