Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not call input methods on the jvm side #747

Open
Frontrider opened this issue Jan 3, 2025 · 5 comments
Open

Can not call input methods on the jvm side #747

Frontrider opened this issue Jan 3, 2025 · 5 comments

Comments

@Frontrider
Copy link

This function call:

  override fun calculateDirection():Vector2 {
        return Input.getVector(
            "ui_left".asCachedStringName(),
            "ui_right".asCachedStringName(),
            "ui_up".asCachedStringName(),
            "ui_down".asCachedStringName()
        )
    }```

Produces this error:
```  Godot-JVM: Error calling JVM method _physics_process of script Player:<CharacterBody2D#32648463773> from Godot:
  java.lang.IncompatibleClassChangeError: Expecting non-static method 'godot.core.Vector2 godot.Input.getVector(godot.core.StringName, godot.core.StringName, godot.core.StringName, godot.core.StringName, float)'
      at neuro.entity.Player.calculateDirection(Player.kt:15)
      at neuro.entity.Entity._physicsProcess(Entity.kt:62)
      at neuro.entity.Player._physicsProcess(Player.kt:26)
      at godot.entry.PlayerRegistrar$register$1$1$2.invoke(PlayerRegistrar.kt:40)
      at godot.entry.PlayerRegistrar$register$1$1$2.invoke(PlayerRegistrar.kt:40)
      at godot.core.KtFunction1.invokeKt$godot_library(Functions.kt:75)
      at godot.core.KtFunction.invoke(Functions.kt:37)

Initial investigation was a bootstrap jar incompatibility, but it proved to be false. Replacing the editor's bootstrap with the one in libs did not solve the problem.

@Frontrider Frontrider changed the title Can not all input methods on the jvm side Can not call input methods on the jvm side Jan 3, 2025
@v79
Copy link

v79 commented Jan 11, 2025

I am also facing this problem. The following code:

override fun _process(delta: Double) {
		var velocity = Vector2.ZERO
		if (Input.isActionPressed("move_right".asStringName())) {
			velocity.x += 1
		}

Produces this error:

Godot-JVM: Error calling JVM method _process of script Player:<Area2D#29913777436> from Godot:
  java.lang.NoSuchMethodError: 'boolean godot.Input.isActionPressed$default(godot.Input, godot.core.StringName, boolean, int, java.lang.Object)'
  	at Player._process(player.kt:33)
  	at godot.entry.PlayerRegistrar$register$1$1$3.invoke(PlayerRegistrar.kt:41)
  	at godot.entry.PlayerRegistrar$register$1$1$3.invoke(PlayerRegistrar.kt:41)
  	at godot.core.KtFunction1.invokeKt$godot_library(Functions.kt:75)
  	at godot.core.KtFunction.invoke(Functions.kt:37)

Brand new project, with v4.3.stable.jvm.0.11.0.gh and Kotlin 2.0.20, utopia-rise v0.10.0-4.3.0.

If I change the call to Input.isActionPressed("move_right".asStringName(), true) with the exactMatch value supplied, I get a different stacktrace error:

  Godot-JVM: Error calling JVM method _process of script Player:<Area2D#29913777436> from Godot:
  java.lang.IncompatibleClassChangeError: Expecting non-static method 'boolean godot.Input.isActionPressed(godot.core.StringName, boolean)'
  	at Player._process(player.kt:33)
  	at godot.entry.PlayerRegistrar$register$1$1$3.invoke(PlayerRegistrar.kt:41)
  	at godot.entry.PlayerRegistrar$register$1$1$3.invoke(PlayerRegistrar.kt:41)
  	at godot.core.KtFunction1.invokeKt$godot_library(Functions.kt:75)
  	at godot.core.KtFunction.invoke(Functions.kt:37)

@piiertho
Copy link
Member

Can you both provide your gradle build script and the JVM version you're using ?

@v79
Copy link

v79 commented Jan 11, 2025

I've just upgraded to 0.11.0-4.3 and the error has gone away. (JDK v17). My character isn't moving, but that's probably a different problem! I am very new.

@piiertho
Copy link
Member

So you were using engine 0.11.0 version with 0.10.0 JVM lib ?

@v79
Copy link

v79 commented Jan 11, 2025

It was a new download of Godot kotlin, and the IntelliJ plugin, and that is what the new project wizard gave me. I've just tried a new project and can confirm that the intellij plugin creates a 0.10.0 project. So maybe an update is needed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants