OK, I’ve been working on this for at least 10 hours here and there without success. How would one program a wipeout-esque game?
For reference, what I have already done:
I didn’t think I could use wheel colliders, so I coded it myself. It used four raycasts, and from that calculated all the important things, such as tilting, repeling, and attracting. However, it was very jerky, and had issues with high speeds.
It then dawned on me that a loose suspension wheel rig might work better. I changed a few other things, but the gist of it is: craft flips over. Mainly, no matter what I do, it won’t bank, instead preferring to flip over and go flying off the track. It then hands control over to a bug in my gravity system and goes careening out of control.
I know this is not rocket science, but it’s starting to feel like reentry calculations would be simpler. Any help?
I think that for a high speed wipeout style racing you want to explicitly control rotation and make the position be driven by physics. So use rigidbody.freezeRotation. Use raycasts to align the rotation correctly based on the surface the ship is hovering over.
This way you get full control over the rotation and a small rock hitting the craft won’t make it spin out of control. On top of that controlling the rotation explicitly, makes it a hell of a lot easier to do things like flying upside down and sliding up on walls.
Honestly there is very few vehicle types where you want to have rotation be controlled by actual physics in a game.
Agreed. distance < 0.5, repel. distance > 0.5, attract. It hugs the track. Worked very well.
You just summed up my first attempt. I guess that means I did it right :lol:
The biggest problem I ran into was it being very jerky. Either it moves smoothly, and keeps hitting the track, it jerks, and looks terrible, or it floats disturbingly high. I think the low poly-ness of the track was causing it, but upping the detail might negatively impact performance. And since I’m making a webgame, every ounce counts (I think). The other idea is compensating for that in code. As to how one would do it, well, that I haven’t figured out. Any ideas?
Nope, web player speed is pretty much the same as stand-alone speed. The main thing to be concerned about when dealing with web players is keeping the size down so they can be downloaded as fast as possible, which usually means keeping textures and sound as minimal as possible (while still getting the effect you want); meshes rarely end up amounting to much as far as size goes.
It’s not that, I’m aiming for the flash games area. My benchmark: the decrepit computers at school. They can play flash games, but Unity is a huge issue. I ran into one computer that claimed it didn’t have sufficient graphics hardware to run iMovie, and not the new one. Not sure how well it handles flash, but you get the idea. It’s not so much size as reducing overhead. And since for fast racing games it’s advised to up the physics framerate as well… :roll:
When generating the rotation, are you using the interpolated normal or the face normal from the raycast? The face normal is going to have discontinuity, so you want to use the interpolated normal. Similar to how you don’t use flat shading in graphics.
You want to smooth the rotation. Easiest is to use Quaternion.Slerp constantly smoothing towards the target by a value slightly less than 1 or so. Expose it in inspector and tweak it. You might also want to look into The SmothDamp function.
Just the face normal of the raycast. What do you mean by interpolated? Interpolated with what? The normal of the poly in front of it? Come to think of it, that’s a good idea. But I see no obvious way to find the triangle in front of a triangle with the mesh script commands. I suppose I could always just have another raycast in front of it. Oh. duh. “I should have thought of this like a million years ago”
True. It was just smoothing so fast to avoid hitting the track.
We have a smooth damp function? That does look useful. Why wasn’t I told of this? Oh, wait, I just was. Thank you