Mostrando entradas con la etiqueta Script para Godot 4.2 al presionar boton del mouse mantiene la rotacion si sigue presionado el boton;. Mostrar todas las entradas
Mostrando entradas con la etiqueta Script para Godot 4.2 al presionar boton del mouse mantiene la rotacion si sigue presionado el boton;. Mostrar todas las entradas

lunes, 12 de febrero de 2024

Script para Godot 4.2 al presionar boton del mouse mantiene la rotacion si sigue presionado el boton;

 extends MeshInstance3D


# Speed of rotation (radians per second)

var rotation_speed: float = 90.0


# Stores button press state

var mouse_button_pressed: bool = false


# Called when the node enters the scene tree for the first time.

func _ready():

pass  # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

# Rotate based on mouse button press and delta time

if mouse_button_pressed:

rotate_z(rotation_speed * delta)


# Called when a mouse button is pressed.

func _input(event):

if event is InputEventMouseButton:

# Handle left mouse button press and release events

if event.button_index == 1:

# Update button press state based on event type

mouse_button_pressed = event.pressed