First, how do you stop the jump from going on indefinitely, as long as the Jump key is held down? I imagine it to be very simple but I can’t get it, but I’m trying to force myself to do this without tutorials.
Second, if you noticed the commented out lines are for a tween. Why are they commented out? 'Cause when they aren’t, they completely break everything. The gravity stops, the inputs don’t work, nothing. I’ve tried to use tweens for other projects in other ways and not once have they worked, but they’ve never broken the entire thing.
What do I do? Is it the way I initialized the tween? Do tweens not go in _physics_process()? Surely it’s got nothing to do with me being on the web version, right?
Input.is_action_pressed checks if the input is pressed, under physics process this happens every frame, there is a Input.is_action_just_pressed that only returns true for one frame on the initial jump press.
Pretty much never put tweens in process functions, it’s very unlikely you want to start a tween every frame. You would have overlapping “skew” tweens if the syntax errors were fixed. Maybe you want to use move_toward to interpolate this skew value towards the desired direction
Figured this out while waiting to get verified lol. Still building my programming head.
Theoretically works, but you can still re-press Jump before hitting the ground, so I slapped on a and is_on_floor() for good measure.
Probably. I still want to learn tweens tho. Can you tell me why the tweens won’t work in this version? This is basically how I’ve implemented tweens every time I tried, so knowing what’s wrong could really help fix my implementations across the board.
Writing a tween describes actions to animate over time, you must declare every property you want to tween at that moment, you cannot add onto tweens while they are animating. A Tween is just not the correct tool for what you want.
Maybe you could use a Tween for a squash & stretch jump animation, but an AnimationPlayer may be better in that case too
The Tween system in Godot needs a load more work to be usable , IMHO. Its basically useless if you are using C# due to garbage collection.
Technically the whole point of the tween system is a lightweight animation player so you dont need to use a full player. However as they are throwaway and cant be reused in any meaningful way, they are next to useless .. again IMHO.
Could you elaborate on this? I released two games already which made heavy use of Tweens, especially the second one which uses C# and was released on both iOS and Android phones, and I never, ever had any issues, even though I was using quite a lot of tweens the whole game.
The issue is in order to use a tween with C# you need a reference to it which will always end up with an allocation. Once that reference is no longer needed its going to be garbage collected. So if you are doing that a lot, then that will build up.
Use something like Jetbrain’s IDE and their GC allocation monitoring tools and you will see what I mean.
YMMV of course as it does depend on the type of game and what the tweens are being used for. Not an issue with GDScript as its immediately removed by the ref counting.
I do not believe this to affect performance in any way, given that, as far as I know, when you call CreateTween it creates a TINY C# wrapper class. Unless you are doing this 60 times a second (which you really should not be doing anyway), then I fail to see how this would affect performance in any real measurable way. There’s a difference between allocation tracking in Rider vs. actual performance bottlenecks.
Note that tweens can actually be reused with a bit of housekeeping. Put a callback as the last step in a tween and let it call stop() on the tween. The Tween object won’t die. If you then call play() on it any time in the future - it will restart. Of course, you’ll have to reset the initial conditions of whatever is tweened if you need an exact replay.
You can wrap this behavior in some sort of ResusableTween class.
Depends on what you are using them for. For example, I (was) in the process of creating an oldschool SHMUP game. And was using a tween on each object to tween shader properties when an enemy got hit (to provide that old school ‘white out’ shield effect).
I was noticing that periodically the games performance would take a dive at regular intervals, and it was being partially being caused by the build up of allocations, of which tweens was one of the culprets.
Of course the allocation for a tween is bytes, but then you have to do something with the tween and every time you do that you are adding even more allocations.
If you doing that on multiple objects all the time ,in this case for every enemy ‘hit’ which could be tens before the enemy is destroyed * multiple enemies on screen , and then run that for an entire run of a level which could easily be hundreds of enemies, and bytes starts turning into MB’s quite easily, all sitting on the Gen 0 heap.
A heap which already has stuff on it anyway with data that you cant avoid putting there (such as level data etc.)
But as stated YMMV, just my experience, I just think that there needs to be a version of tweens that are not disposible , that way you could pool them up and use them as and when.
For a bit of fun, here’s a quick wrapper implementation. It’s GDScript because I’m a bit allergic to C# but I’m sure it can be wrapped even more elegantly with C#
Sure but I think it’d require some work if you want to bring it on par with Godot’s tweens. They’re packed with features. There’s a lot more there than just lerping.