getting_started/first_3d_game/07.killing_player #62
Replies: 17 comments 30 replies
-
Unless I've missed something, in the tutorial player script (using GDScript), the line: I'm not sure where this changed in the tutorial? (Though it is possible I did skim over it) |
Beta Was this translation helpful? Give feedback.
-
I can't figure out why my collisions are backwards? When I hit a mob from the side I jump and when I jump on top of a mob, I die... Mobs stop spawning just like if i died, so the reactions are indeed backwards... |
Beta Was this translation helpful? Give feedback.
-
If the Mob spawns while the Player ïs in the air. The mob will be rotated towards the player and have their geo crashing through the floor. To fix this you need to modify the mob's initialize function: func initialize(start_position, player_position):
#Ignore the y-axis to keep the mob flat
var flat_player_position = player_position
#Set the player's y position to the same as the mob's starting position
flat_player_position.y = start_position.y
#Now look at the player horizontally, but keep the mob flat
look_at_from_position(start_position, flat_player_position, Vector3.UP)
rotate_y(randf_range(-PI / 4, PI / 4))
var random_speed = randi_range(min_speed, max_speed)
velocity = Vector3.FORWARD * random_speed
velocity = velocity.rotated(Vector3.UP, rotation.y) |
Beta Was this translation helpful? Give feedback.
-
The player can just run off the screen. Any ideas to fix this? |
Beta Was this translation helpful? Give feedback.
-
Is the "hit" signal really needed in this tutorial (and the 2d tutorial)? can't we just connect the body_entered signal to Main directly? |
Beta Was this translation helpful? Give feedback.
-
Why turn off both |
Beta Was this translation helpful? Give feedback.
-
For me, the player would never die. I don't know if the "OnMobDetectorBodyEntered(Node3D body)" function isn't working properly, but adding an "else { Die(); }" at the end of the for loop checking to see if the player has hit the mob from above fixed the issue. |
Beta Was this translation helpful? Give feedback.
-
after I added the signals the player disappears as soon as the game starts |
Beta Was this translation helpful? Give feedback.
-
This is very strange. Playing with my arrow keys, I can move in all 8 directions no problem. Playing with WASD, I have no such problem. I have tried reassigning the Input Maps so that the WASD keys are added before the directional keys, and vice-versa, but no help. I'm using a MacBook Pro Retina, Mid-2014: |
Beta Was this translation helpful? Give feedback.
-
is there a way to get rid of the error that happens after the player dies |
Beta Was this translation helpful? Give feedback.
-
Logically speaking, if you just wanted to detect the collision against the mobs from anywhere other than the top (which you are detecting already) you could just add an # If the collider is with a mob
if collision.get_collider().is_in_group("mob"):
var mob = collision.get_collider()
var normal = collision.get_normal()
# we check that we are hitting it from above.
if Vector3.UP.dot(normal) > 0.1:
print("Squash it!")
# If so, we squash it and bounce.
mob.squash()
target_velocity.y = bounce_impulse
# Prevent further duplicate calls.
break
else:
# Handle collision from front, back, or sides
print("Hit from the side, front, or back!")
# Game over logic here...
break ps. just wanted to say a quick thank you for whoever worked on these tutorials, they are really helpful for noobs like me, and are a great way to learn about the Godot engine. I hope we will have more of them in the future :) |
Beta Was this translation helpful? Give feedback.
-
For anyone having problems with the MobDetector detecting enemies: make sure the For reference, the relevant collision sizes I use are Player/CollisionShape3D: SphereShape Radius 1.0 m
Player/MobDetector/CollisionShape3D: CylinderShape Height 0.3 m, Radius 1.2 m
Mob/CollisionShape3D: BoxShape Size(1.5 m, 1.2 m, 2 m) |
Beta Was this translation helpful? Give feedback.
-
Reminder that if the squash isn't working, check if the Mob group exists. Wasted 30 minutes on fixing it :) |
Beta Was this translation helpful? Give feedback.
-
I couldn't make the "if Vector3.UP.dot(collision.get_normal()) < 0" work properly, so I made another Area3D just for squashing the mobs. It is below the other MobDetector and it has a smaller radius |
Beta Was this translation helpful? Give feedback.
-
I had a problem with my MobDetector, which was not emitting any signals. I don't remember exactly, but I think I also had to enable the same for the Mob collision on the previous page of the guide, in order to be able to trigger the signal by jumping on it. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for the tutorial! Question: my character doesn’t die. Any suggestions? |
Beta Was this translation helpful? Give feedback.
-
Hey guys I'm trying to make a 2d text appear that says "Squash!" whenever player lands on a mob, I know Godot does 3d/2d interchangeably, but I'm losing my mind trying to figure out how to specify that I want the 2d text to appear at a specific position (a little higher than where the even occurred). I know there's get_camera_3d.unproject_position(), but I'm trying to add it to the squash() function b/c that makes the most sense, and the camera is off in the main scene. I've never worked with 3D; how can I do this? I've got it so the text does appear at the right time, but it's always in the center of the screen. I asked at r/Godot and was told "You can’t use a Vector2 (two dimensions) to set the position of a 3D (3 dimensions) node." - which I knew in the first place, which is why I have the Label inside a CanvasLasyer, inside a Node2D that's inside a Node3D. It seems like there would be a fairly simple way to do this. Could someone give me some guidance here? I'd really appreciate it. |
Beta Was this translation helpful? Give feedback.
-
getting_started/first_3d_game/07.killing_player
We can kill enemies by jumping on them, but the player still can't die. Let's fix this. We want to detect being hit by an enemy differently from squashing them. We want the player to die when they'...
https://docs.godotengine.org/en/stable/getting_started/first_3d_game/07.killing_player.html
Beta Was this translation helpful? Give feedback.
All reactions