Posts: 1,059
Threads: 66
Joined: Jul 2018
Reputation:
52
02-29-2020, 12:33 PM
(This post was last modified: 02-29-2020, 02:05 PM by emalafeew.)
I’ll post the relevant code and parameters shortly. Each of our avatars subclasses VZPlayer to extend its capability. In the Pegasus case we generate a lift force proportional to pedaling speed when the A button is held down, that is tuned to achieve liftoff at 65 rpm. It also has the concept of a flight ceiling, so the lift force faces an increasing downward ceiling force, which equalizes when Pegasus is at ceiling height pedaling 130 rpm.
Posts: 1,059
Threads: 66
Joined: Jul 2018
Reputation:
52
The game tip you might be able to glean from this code is that the ceiling pressure is proportional to VZPlayer.Altitude(), which is relative to the height of the player when they begin flying. That altitude does not continuously adjust for the ground height under you when flying, so flying difficulty is purely a matter from when you last touched ground. So in Gem Hunt, to be able to fly higher for gems in the air, begin your takeoff from a higher point. This can also help you in Gate Race when taking shortcuts.
Posts: 159
Threads: 13
Joined: Mar 2019
Reputation:
10
Thanks!
I'm new to Unity and mostly only dabble in development so bear with me - I am getting an error with this code.
For now what I am trying to do is essentially just add flying to the default avatar that is in the generic "scene" provided with the SDK. So I created a FlyingBike.cs script that contains the code you provided and added that to the existing VZPlayer object that represents the bike (and has the VZPlayer script already on it.)
I get the following in Unity:
'VZSimplePegasus.FixedUpdate()': no suitable method found to override
Looking through the default VZPlayer.cs code I do not see a FixedUpdate() method though I do see Update() and UpdateNormal() (along with UpdateSetup and UpdateNeck) -- should I be using one of those instead of FixedUpdate()?
Posts: 1,059
Threads: 66
Joined: Jul 2018
Reputation:
52
Ah we’re using an updated sdk internally.
To make it work just take out the words “protected override” from FixedUpdate
Posts: 159
Threads: 13
Joined: Mar 2019
Reputation:
10
So I think I ran into some issues with subclassing, either because I was using the virzoom bike prefab instead of my own avatar or because I did something wrong....but I was able to just modify the VZPlayer script directly and add this on and got a flying bike. Very cool! Thanks for the info, very helpful so far. I'm not much of a developer (though I do work in tech) but I think I'll be able to cobble together some fun stuff...
Posts: 1,059
Threads: 66
Joined: Jul 2018
Reputation:
52
03-01-2020, 08:38 AM
(This post was last modified: 03-01-2020, 08:38 AM by emalafeew.)
Ah yes, I forgot to say you should remove that line as well. Or add it to the base VZPlayer which you did. Good job on getting there!
The unity store has lots of models you can buy for $10-20, which you could hookup in place of our bike model. Animate them and make an environment with scoreable interactions and you’ve got yourself a game!
Our latest internal sdk has that fixed update call for the camera smoothing in our latest Explorer build. So yeah we could release that, but I’ll also be sure to provide sample code that works with our current released sdk in the future.