I’m currently in the process of taking my game from prototype to Alpha; one of the things that requires is changing the event ticks, since currently gameplay and mechanics can vary depending on the frame rate.
I know you can use delta time to set the tick rate as a constant, but I’m completely lost on how to do this.
Also, this of course makes the character move extremely slow (which is where I imagine multiplication comes in) - but how would I set up the maths side to basically make delta time speed the same as it was using event tick at fixed at 60fps?
Also, how would this work for blueprint nodes that do not have a float input?
When you multiply something with delta time that value becomes “units per second”. In your picture here the Forward vector will look something like (1, 0, 0). That means it moves 1 unit per second. UE4 uses 1 unit = 1cm by default and that’s why it’s moving slow.
And of course if you multiply a rotation rate with delta time it becomes degrees per second.
Ideally you should have variable whcih defines the Rate (in this case MovementRate) whcih is the change per second. You multiply that variable with delta time and this will give you the actual amount of change.
Here is a small example. You should adapt it to your need. In my example, the variable CameraMoveSpeed defines how fast camera moves (ie cm/sec). I multiply it with delta time (Get World Delta Seconds) and feed it to AddMovement node.
Currently I am multiplying movement speed (variable set to 120) by delta time, which seems to give the result I was looking for. Essentially the same speed I had when using the event tick the standard way.
The visual is extremely useful, thanks. Also, I never realised you could access Delta Seconds that way, which has helped a lot. (See above comment with image)
Is there a way to use this with a node that does not take float or rotation inputs?
For example, I have an event tick comparing two integers. Although not as game breaking as say, movement speed varying, is there a way to also use delta time for this?
I’m 100% new to coding - I love blueprints but when it ventures in to coding territory I’m a little stumped.
I don’t quite follow. Could you elaborate it further?
What are you trying to achieve here. I see that you are doing a comparison, and you have not specified what to compare with. Are you trying to compare Delta Seconds against an integer?
Blue-prints support casting one type of variable to another (this is not alwsy possible when objects are involved). But you can convert between floats and integers.
Actually you only need to update the HasBananas variable only when you either acquire or lose a banana. You dont have to do it every tick - unless ofcourse you gain/lose banana over time (ie you get a banana every 5 seconds…).
I cannot answer this with 100% accuracy since I dont know how you have implemented the rest of the system. So I am giving you a simple scenario and how I would do it:
You gain a banana when you touch a banana (bananas are present in the world as pickup items)
You lose a banana when you suffer a damage.
So here, I will increment BananaCount and update HasBanana to TRUE on the function Hit and decrement count on TakeDamage (and possibly set HasBanana to false, based on a ‘>/<’ condition (type ‘greater than’/‘less than’ in blueprint).
Unreal calls the Tick() function once in every frame. I dont think you can alter this.
Ideally put only those code that you need to run continously inside Tick() function. Code that needs to be executed on an particular event should be moved to appropriate event handlers (eg: Touch, Key Press, …)
About delta time:
Liek I said, Unreal calls the Tick() function on every frame. In an ideal case it will be called 60 times per second. But that is not always the case. Sometimes your code might take more CPU time and result in fewer ticks per second. So you cannot assume that the duration between each Tick() is the same. To counter this, Unreal will pass the time elapsed since last time Tick() was called. That is ‘DeltaTime’. YOu only need to use it when you logic depends on time passed (like a spell recharge logic, where player must wait a certain time unilt he can use a spell again…), or update some variable based on change rate
Thank you, that was very interesting and helpful to read. It’s certainly allowed me to fully understand how event ticks work, as well as delta time.
Initially that is how I had it set up, the engine checks the banana count on collision with the object - if it’s zero, they die, if not they lose bananas and are launched backwards, to try the jump again.
But I had an issue that it would cause the events to fire twice, since it seems the blueprints fired too fast. The collision would be checked twice so the player would die no matter what.
The blueprint would check, see bananas, minus them, check them again then destroy the character. So the collision was happening multiple times before the character was being launched.This is why I had the check set to event tick. However since taking a short break from working the solution hit me.
I added a DoOnce node at the start, that was only reset by the final node firing and a 0.2s delay - which fixed it.
The event tick was a lazy way of fixing it which I guess was not ideal for CPU usage etc. Thanks for the great help. I understand things a lot more now.