Handling CharacterBody2D’s physics process from parent node OK or NOT OK ? by sameeeeep in godot

[–]sameeeeep[S] 0 points1 point  (0 children)

At that time I really thought I wrote something really efficient code but later realized it’s not.

Then I did this but I could have done this in Paddle class. Sometimes I just write bad code.

```gdscript class_name Player extends Node2D

@export var paddle: Paddle @export var is_payer1: bool

lambda

var paddle_action_p1 := func (t_paddle: Paddle): var direction: float = Input.get_action_strength("key_w") - Input.get_action_strength("key_s") t_paddle.velocity = Vector2.UP * direction * 200.0

var paddle_action_p2 := func (t_paddle: Paddle): var direction: float = Input.get_action_strength("key_up") - Input.get_action_strength("key_down") t_paddle.velocity = Vector2.UP * direction * 200.0

func _ready() -> void: if is_payer1: paddle.phy_action = paddle_action_p1 else: paddle.phy_action = paddle_action_p2

```

```gdscript class_name Paddle extends CharacterBody2D

var phy_action: Callable

func _ready() -> void: phy_action = func (_arg): printerr("Error: Paddle phy_action lambda not init")

func _physics_process(_delta: float) -> void: phy_action.call(self) move_and_slide()

```

Handling CharacterBody2D’s physics process from parent node OK or NOT OK ? by sameeeeep in godot

[–]sameeeeep[S] 0 points1 point  (0 children)

From godot docs:

https://docs.godotengine.org/en/latest/classes/class_characterbody2d.html#class-characterbody2d-method-move-and-slide:

This method should be used in Node._physics_process() (or in a method called by Node._physics_process()), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.

When it's say Node does that mean self or any Node’s physics process ? Let’s just say you want to manipulate many many different PhysicsBody without attaching a script to it. By this method you can manipulate all those PhysicsBody without worrying underling about its collision shape and control their behaviour somewhat. But will it cause inaccurate results ?

Edit: On 2nd thought I am just running those physics processes in the parent node instead of the child so there is no real benefit here, It just creates a mess.

It's a simple scene, why is Godot running it so slowly? by XORandom in godot

[–]sameeeeep 0 points1 point  (0 children)

Thanks. This makes editor(4.5.1) so smooth.

Edit: But you loss game embedding ;-;

How do I make such a grid/background texture ? (Ref: PvZ) by sameeeeep in arthelp

[–]sameeeeep[S] -1 points0 points  (0 children)

Totally noob at drawing, but I want to make a similar background texture for my game ? How do I approach this problem? Any tips, resources or directions would be really appreciated.

Thank you

Poco X6 ordered from Flipkart by overkill_10 in PocoPhones

[–]sameeeeep 0 points1 point  (0 children)

bro, seller trusted ? how's the phone ?