How to create structure destruction like Fortnite in Unity? - unity3d

I'm trying to make a fan remake of Fortnite. I already made a construction system and editing, but I don’t know how destruction can be done. https://www.youtube.com/watch?v=hwuvoOXL2vw
This how it looks in Fortnite - https://youtu.be/EGXYWceVUPU
Do you have any ideas how to do this? I tried through checking neighboring cells, but this is not optimized or I did something wrong.
I will be glad to any advice!

Using raycasts, you can send out a raycast whenever the player wants to hit something, then if the object has the script that means it can take damage (maybe just use a tag for this), then it will take damage from the object. You could use Brackeys' FPS Shooting tutorial, and adapt that to suit your needs.

Related

Unity3D Wheel Collider - Friction Curve? Alternatives?

so I've been trying to see if I can make use of Wheel Colliders for the past several months now. As much as I've managed to figure out more and more things about how to set them up properly, there's some things I've been noticing that seem impossible to avoid:
Even if your friction sideways stiffness is lower, there's a chance that your car will continue to "spin" or "rotate" in the direction you were steering if you JUST hold down your input long enough to get the car beyond just rotating. I've noticed this will happen, whether for example the "SteerHelper" or "TractionControl" functions are doing their work or not. This will put a dent in ensuring smooth turn movement. Now, I don't know if maybe this is just due to realistic car physics (I mean, I can picture the car skidding in scenarios where they lost grip of the road for sure), but it just feels kinda glitchy. Sometimes, even when I'm not turning, the car will start to turn a little to the left or right and then gradually seem to "lean" that way in terms of applied torque to the rigidbody. I've seen many suggestions for trying to stop the rigidbody from doing this. Here is one way I'm trying to work against this:
rb.AddTorque(-rb.angularVelocity * 2);
However, it seems that the car will still "spin" more than intended. What would be ideal is to be able to MAYBE allow the car to turn a little extra after the left or right steer buttons were released (maybe more or less depending on the vehicle), and no more than that to ensure there is maximum control to give the engaged and maybe arcadey game play I've been going for for a long while.
It's been difficult to adapt an ideal friction curve value that would give the most ideal feel of a drift turn, especially a more arcadey one. I'm not trying to go for wide turns that slow you down, I'm trying to go for tight (yet controllable) turns that allow you to preserve most of your speed. I find that especially at higher values of stiffness, as I know many people have observed in other posts, that again, the car will turn back an extremely high amount sometimes (you drift left enough, a force is turning your vehicle way to the right). It's sad, because I've wanted to be able to say I've "mastered this beast" and used it for my purposes, but I don't know if that's really a good practical expectation for anyone. I even worked my own alternate friction curve values that would be used in the controller:
But I guess as some people say, you can't polish something that's broken? Moving to the third point...
I've read so many posts that show how to adjust a vehicle's center of mass, or to add more colliders in different spots to correct it, using scripting to add an offset to the center of mass, etc. So many tips that say, "lower the center of mass, you'll find it" and I give that a try. When the center of mass is too low, my car can get pretty shaky on the terrain (not that it hasn't in the past, but it's often been things I could correct, like the weird initialization of the attachedRigidBody of the wheel colliders themselves in the beginning, etc). High enough, and of course, (even when it's lower sometimes???) the car will just start spinning in the air on either multiple axes or specifically the forward z, when you drive off a ledge or bump into something with a high enough speed. It just seems inevitable.
I've been trying to give my benefits of a doubt. I like to think there's a correct way to use this thing, and that I'm just not familiar enough with Unity3D physics concepts. However, it just seems more and more that I'm investing too much time in a broken component - or, maybe I just never got the best grip of physics.
I was about ready to try just convex mesh colliders around my tires, and just abandon the idea of gripping physics altogether, but I'd love to hear suggestions to either address anything I've mentioned above, or just a more ideal package to move onto. I've glanced at packages like Vehicle Physics Pro, but I do want to be sure I'm getting something that makes sense.
Full disclosure: I'm in the middle of trying to make a game that feels incredibly similar to F-Zero, but with wheels.
Thanks in advance for any thoughts or suggestions you can provide.
(Maybe not an answer per se, but hopefully helpful.)
Note Unity also suggests to possibly give the car a constant downward force via script. It might be telling that such workarounds are officially given, one would think proper physics would, well, properly work without them.
There's some assets you might want to give a try generally:
One is the Unity Asset Store asset called Arcade Car Physics, and it's free. I've tried it and it works (but not sure if it works for your needs). It's using Unity's native Wheel Collider plus extra scripts.
Another is the Arcade Car Physics github project. It has nice plane stabilization and more, and works well. It's not using the native Wheel Collider.
Then there's this asset called Vehicle Physics. Instead of native Wheel Colliders, they've create a fully custom wheel system so that it would be more physically workable. The asset is not free, but they offer a free demo executable where you can drive around different vehicles, and that works quite well. (I haven't yet bought this asset myself.) As a downside, some reviews mention there's some complexity in setting this up (and I suppose future support for this custom Wheel Collider hinges on the company continuing to exist).
Good luck!

VR: How to form hands around object they are holding in Unreal?

I'm working on a VR project in Unreal and I'd like my player hands to form to certain objects whenever the user grabs them. (I.e. the way our hands work) Unfortunately, I haven't really found any examples online of others doing this.
For example, I'd like when the user picks up say a hand held tool like a hammer that the hand would wrap around the handle. When the user grabs a basketball the hand shouldn't be closed but, expanded like a you would if you were to palm a basketball in real life.
I haven't done a lot of testing with this but, I'm pretty sure since the hands are based off of a Animation Blueprint that they simply ignore collisions and follow the animation.
I guess the simplest solution would probably be based off of collision where the hand plays an animation and as the fingers of the hand wrap around the object they stop at that position where they collide with the object in question. If it is even possible that is.

Why when I drag something using IDragHandler IPointerEnterHandler not always working on another object?

I'm trying to implement drag and drop using unity's EventSystem. When I start drag one object using IDragHandler - IPointerEnterHandler on another object doesn't works from time to time. Does someone know how to solve this? Or maybe someone know the reason why this restriction existing?
Since EventSystem works with raycasting, there may be another object which blocks the ray. So, you should make sure there is no other object that may block raycasts.
If you are using dragging for UI elements you can change other objects CanvasGroup to canvasGroup.blocksRaycast = false or you can set it as lastSibling https://docs.unity3d.com/ScriptReference/Transform.SetAsLastSibling.html.
If you are doing it with gameObjects you can change your object's layer to something higher from others. Such as 10. But do not forget to make it default again when you are done with it.
If you can share a gif or something else, it would be easier to help you.

Unity3d Silhouette Highlight for 2d sprite

I want to implement Silhouette Highlight on MouseOver like in this picture:
Built in Unity3d user interface elements have a component called Outline and Shadow, but they only work with the user interface, not with the SpriteRenderer. The first idea was to create a second sprite with highlight at background and enable it to MouseOver, but I think that this method is not good.
As Everts (and me) mentions in a comment,
there's nothing wrong with simply making the "glow sprites" and turning them on and off. That would certainly be done in many large games: it's good.
It's true that you could write a shader that does this, but really that would be "bad engineering" - totally unnecessary for such a simple need. (And to be clear, arguably it's plain better to make custom sprites.)
Now, this brings us to an important point about Unity engineering -
it's critical to use existing assets, in Unity work.
There are a couple of stand-out examples. Like, NatCam and Edy's vehicle system. You just - literally - cannot use the camera in a game unless you use "NatCam"; the only alternative would be to completely pointlessly spend a year building NatCam yourself.
In this case, there are many good "glow shaders" available ...
https://www.assetstore.unity3d.com/en/#!/content/20166
Enjoy!

Should I change draw order?

I'm creating mobile racing(in space) game and it's first person so there is always big cockpit occluding big part of scene. Can I somehow use the fact that I know it to optimize rendering? I have heard that draw call order can be changed, but I don't know how exactly it would work.
The thing you are looking for is called "Occlusion Culling". Here is a guide from the Unity manual explaining how it works and how to set it up.
NOTE: This only culls static objects, if your cockpit moves with the player objects covered by the cockpit will not be culled by using this method. If you want to do occlusion culling with dynamic objects you need to get a 3rd party asset from the store like InstantOC, it even has a "Mobile Aircraft Controls" prefab (Note, I have never used InstantOC but I have heard good things about it).