Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Denzere |
Im on the version 3.2.1 of godot, for what i have seen on tutorials in order to code my kinematicbody and move it, i need get_global_mouse_position but when i wrote it the progam doesn’t recognize that code. Instead i think i need to use global_transform but i don’t know how to use it.
What other method could i use to move a KBody3D with a mouse? if you can provide the code it would be awesome.
what camera view is this? Is it a top down? Third person?
Millard | 2020-05-21 16:43
Im a newbie so, i think it is called Eagle View, from the sky, but if im not mistaken it is the same as Third Person but from a higher perspective? if that’s the case what should i do?
Denzere | 2020-05-21 16:49
What tutorial are you following? Have you checked the 3d navmesh template? It has a point and click system for movement. It uses rays cast from the camera to calculate where has been clicked.
DamonR | 2020-05-21 22:04
This is one of the tutorials i have been following: https://www.youtube.com/watch?v=_urHlep2P84
And this from the Godot Manual: 2D movement overview — Godot Engine (stable) documentation in English
Some of the code lines doesn’t work on 3D so im a bit confused
I’m aware of the point and blick system on 3Dnavmesh but im not sure how to to link the signal that the RayCast emits and link it to the KinecBody in order to make it move
Denzere | 2020-05-22 20:20
Do you have an example of the code you’re using? I know some things are very different between 2D and 3D, I mostly work in 3D, as that’s just my preference.
From what I remember, the navmesh example doesn’t use a signal, it uses the raycasts to get a position, which it then uses. But the navmesh example uses a master code to run the scene. I used it to figure out how to create enemies which use a navmesh for movement from within their own code. I haven’t used it for a point and click system.
I think there is (or was) a point and click add-on for Godot. Esporia I think.
DamonR | 2020-05-23 00:35
The Godot 3D point and click framework is Escoria (I was so close).
I haven’t tried it myself, but it may have something you find useful.
DamonR | 2020-05-23 00:41
This is the exact code I’ve been using so far
extends KinematicBody
var max_speed = 400
var speed = 0
var move_direction
var acceleration = 1200
var moving = false
var destination = Vector3()
var movement = Vector3()
var position = Vector3(0, 0, 0) # ?
func _unhandled_input(event):
if event.is_action_pressed(‘Boton_derecho’):
moving = true
destination = global_transform # here is wherei had the most trouble so far
func _physics_process(delta):
MovementLoop(delta)
func MovementLoop(delta):
if moving == false:
speed = 0
else:
speed += acceleration * delta
if speed > max_speed:
speed = max_speed
movement = position.move_direction(destination) * speed
move_direction = rad2deg(destination.angle_to(destination)) #angle_to doesnt work on 3.2.1
if position.distance_to(destination) > 5:
movement = move_and_slide(movement)
else:
moving = false
For this code I followed a 2D tutorial and changed some lines with I know so far to be able to work on 3D
This is the video where i saw it: https://youtu.be/05OixHPbxNA
Denzere | 2020-05-23 17:50
I will check it (y)
Denzere | 2020-05-23 17:51