Home Indie Game THE MILKMAN – Milk Delivery Game

THE MILKMAN – Milk Delivery Game

0
THE MILKMAN – Milk Delivery Game

[ad_1]

Your devlog could be very detailed! Wishing you all the very best with ending this sport up – it seems to be like an excellent studying train. Coffee

Simplifying code (or tips on how to complicate issues additional)
I then remembered that there was a remark suggesting that I take advantage of the operate rework.Forward. I understood it to imply that I may save plenty of strains of code. Long story quick, it did not actually assist and if you wish to see the comedy ends in attempting to make it work, go forward and take a look at my newest video DevLog right here:

I do know nothing about Unity particularly however here is my interpretation of what the rework.ahead code is doing, assuming Unity behaves how I’d count on it to Grin . I did not see any rationalization like this within the youtube feedback so it may be useful to be taught what went incorrect.

rb.velocity = civTruck.rework.ahead * forwardSpeed

“rb.velocity =” is setting the rate of the inflexible physique. This is overriding any velocity that the physics system has beforehand calculated which is why the vehicles not appear to care in the event that they collide with the participant’s car and hold pushing forwards, and are not affected by gravity, and so forth.

rework.ahead provides you the present ahead vector of the automobile. So the results of this code is just to make the automobile transfer alongside that ahead vector on the “forwardSpeed” pace. If the automobile is completely flat on the highway and pointing in the correct route then that is wonderful. But as quickly because the automobile begins to level in a unique route, it will begin to transfer in that route as an alternative. Cars that time barely into the air will begin to fly and vehicles that time all the way down to the bottom will hold pushing down into the bottom.

Rigid our bodies even have a rotational velocity (how briskly the angle is altering) which is not being overridden like the rate is. So if the automobile is hit by one thing it might begin to spin in accordance with physics. This explains the behaviour the place the vehicles are floating via the air however nonetheless freely spinning.

If you do nonetheless need to enhance this space of the code: I’d recommend splitting the issue into first deciding the place the automobile needs to be (a place within the right lane of the highway however additional alongside it?), then some mixture of turning or shifting in direction of that concentrate on place. The Unity inflexible physique ought to have some form of operate like “ApplyForce” or “AddForce” which might be the proper method to affect the automobile’s motion with out overriding the rate utterly.

Alternatively there might be some helpful function already constructed into Unity that may enable the automobile to navigate itself in a better approach? (Or, as a final resort you might simply have any vehicles that stray off the highway explode, then they’re not an issue Evil )

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here