0 votes

I have some script "Jumpable" which has some variables

export(float) var hang_time : float = 3
export(float) var jump_speed : float  = -400

I have a script Deer and a script Player which both extend Jumpable, I'll use the player as an example

extends "res://Scripts/Jumpable.gd"

export (int) var run_speed = 100

So hangtime and jumpspeed both show up as values to be changed in my editor for the player

https://imgur.com/a/4LqT85e

but the changes I make in the editor don't affect the script at all, instead they retain their default values. But when I make changes to run_speed(which is not inherited, but specific to the Player) all works well. So I think this is a problem related to the fact that I'm inheriting these export variables. Thanks in advance.

asked Nov 2, 2019 in Engine by Wasiim (25 points)

1 Answer

+1 vote
Best answer

Is there a Jumpable.tscn scene that the Jumpable.gd script is attached to? If not, create one, and then use the Scene > New Inherited Scene... menu option, select Jumpable.tscn to create a new scene which inherits Jumpable.tscn. You can change the node name, then and save it as Deer.tscn or Player.tscn. From the new nodes, detach Jumpable.gd and create and attach new script, and from that new script extend Jumpable.gd.

Following those steps works for me.

answered Nov 2, 2019 by Eric Ellingson (1,581 points)
selected Nov 6, 2019 by Wasiim

I'm not sure why but I'm able to override the Player's value in my game scene and it works, but I can't for the Deer. Maybe I'm missing something. Check out the pictures below.

https://imgur.com/a/brTs0HM

Ah, when I didn't create a Jumpable.tscn scene, it worked. Maybe it's because I had Jumpable.tscn on a KinematicBody2D, rather than a plain Node? who knows.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.