Godot Version
4.3
Question
since I’m scaling my player in real time this makes it very easy for the player to get stuck in the ground or ceiling if done right. Is there any way I can stop the player from clipping into things?
here’s my code for scaling:
part of the code on the player:
func _ready():
area_2_dx.connect("clickedxmodifier", _on_clickX)
area_2_dy.connect("clickedymodifier", _on_clickY)
func _on_clickX(NEWSCALEx):
player.scale.x = NEWSCALEx
print(NEWSCALEx)
func _on_clickY(NEWSCALEy):
player.scale.y = NEWSCALEy
print(NEWSCALEy)
here’s my code on the Area2D. There’s a script for the Y axis too.
extends Area2D
signal clickedxmodifier
@onready var scaleui_2: Sprite2D = %Scaleui2
var has_mouse:bool = false
var STARTSCALE = 1
var NEWSCALE = 1
var MPOS = 0
func _mouse_enter():
has_mouse = true
func _physics_process(delta):
if Input.is_action_just_released("click"):
has_mouse = false
if has_mouse and Input.is_action_just_pressed("click"):
MPOS = get_viewport().get_mouse_position().x
STARTSCALE = NEWSCALE
if has_mouse and Input.is_action_pressed("click"):
NEWSCALE = STARTSCALE + (get_viewport().get_mouse_position().x - MPOS) / 100
NEWSCALE = clamp(NEWSCALE, 0.5, 7)
scaleui_2.scale.x = NEWSCALE
scaleui_2.position.x = NEWSCALE
clickedxmodifier.emit(NEWSCALE)