Godot Version
4.4
Question
My player wass good, but after I deleted and added again in my main scene after playing it started to look like this and I can't fix that.
I don’t think the problem is in the code but I can provide if it’s needed.
4.4
My player wass good, but after I deleted and added again in my main scene after playing it started to look like this and I can't fix that.
What is your player? What are they supposed to look like?
My player is the triangle, and it supposed to look like that only the position in incorrect, it’s must be on the circle not forward it. This is how it must be, only there I use triangle. https://www.youtube.com/watch?v=JvJVVCi-Doo
Is your player offset from it’s scene origin? Can you share the player’s scene tree and the 2D viewport
That is the 2D viewport Offset also looks good. By offset I mean how far the sprite/collision is from the 0,0 marker, not the offset property.
But then how are you rotating the player around these circles?
Need I now show my collisions distance? Also I am moving my player with code
class_name Player
extends CharacterBody2D
@export var orbit_radius: float = 100
@export var orbit_speed: float = 2.0
@export var jump_speed: float = 400
var landed: bool = false
var orbit_angle: float = 0.0
var orbit_center: Vector2 = Vector2.ZERO
var jumping: bool = false
var jump_target: Vector2 = Vector2.ZERO
func set_orbit_center(pos: Vector2):
orbit_center = pos
orbit_angle = (global_position - orbit_center).angle()
jumping = false
func _ready() -> void:
orbit_center = global_position
$Area2D.connect("area_entered", Callable(self, "_on_area_entered"))
$Camera2D.enabled = false
func _process(delta: float) -> void:
if jumping:
var dir = (jump_target - global_position).normalized()
global_position += dir * jump_speed * delta
if global_position.distance_to(jump_target) < 10:
jumping = false
rotation = orbit_angle + PI / 2
await get_tree().create_timer(0.1).timeout
if not landed:
print("missed, game over")
get_parent().game_over()
landed = false
else:
orbit_angle += orbit_speed * delta
global_position = orbit_center + Vector2(orbit_radius, 0).rotated(orbit_angle)
rotation = orbit_angle + PI / 2
func _unhandled_input(event):
if not get_parent().game_started:
return
if (event is InputEventScreenTouch and event.pressed) or (event is InputEventMouseButton and event.pressed):
if not jumping:
jumping = true
var jump_vector = Vector2(orbit_radius, 0).rotated(orbit_angle)
jump_target = global_position + jump_vector.normalized() * 400
print("🚀 Jumping!")
func _on_area_entered(area: Area2D) -> void:
if jumping and area.get_parent() == get_parent().next_orbit_node:
print("landed")
jumping = false
orbit_center = get_parent().next_orbit_node.position
get_parent().player_landed_on_orbit((orbit_center))
func enable_camera():
$Camera2D.enabled = true
func reset_position(center: Vector2):
set_orbit_center(center)
global_position = center + Vector2(orbit_radius, 0).rotated(orbit_angle)
Seems like your code has orbit_radius
accounted for, what have you tried setting that to?
Bruh, I forgot that I created that, I make it 100 and thats why it was too far, but before was good Idk why but now I put 60 and it works fine, thanks for the help, I appreciate it!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.