this post was submitted on 24 Jul 2025
10 points (100.0% liked)

Godot

6931 readers
1 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

I'm working on a two player 3D game that involves both player character models facing toward one another most of the time.

I worked out that i can use translate_object_local(Vector3.MODEL_<side>) for movement around a point that a model faces toward (there's probably a better way to do that, but that's not what i'm focused on for now), but i'm struggling to make that focus point an object instead of just coordinates.

I've tried a few things inside func _physics_process(delta): look_at($Beacon.position.x, Vector3.UP, $Beacon.position.z) to rotate around the Y axis and face the object Beacon (CharacterBody3D placeholder for player 2) crashes with the error "Invalid access to property or key 'position' on a base object of type 'null instance'."

Putting var look_here = position in the script for the beacon and then look_at($"../Beacon".look_here) in TestChar (test character) makes the character rotate around the world origin.

Adding a Vector3 variable look_here_P1 to Beacon's script and then adding or subtracting to its X and Y positions with beacon's movement keys should make TestChar face a point that's in the same place as Beacon, but i don't know how to either make TestChar use that that variable from Beacon's script, or move the variable to TestChar and make Beacon update it now that it's in another script.

Making Beacon emit a signal every time it moves in a particular direction and then using those signals to update a Vector3 variable in TestChar's script doesn't seem to work, i think either it doesn't update the variable's position or look_at() in _physics_process doesn't check for a new target to look at.

Is there a simple way to make an object always look at another object? I'm sure there must be but i can't seem to figure it out. Thanks in advance.

you are viewing a single comment's thread
view the rest of the comments
[–] ConditionalCoder@mastodon.gamedev.place 0 points 1 week ago (1 children)

@IndigoGollum Tell each object that the other object is prettier than they are.

[–] IndigoGollum@lemmy.world 1 points 6 days ago

Sure, what's the syntax for that⸮