Make Unity tiles do different things - c#

I was just wondering, how I can add different scripts to tiles in the same tilemap in unity. Say I have a tilemap with spikes and normal ground, I only want the spikes to have the killing effect. It is kind of tedious to make a new tilemap where every tile kills you, just that I can add that mechanic to the spike. Can I do this in one Tilemap!?
Thanks a lot, I really appreciate it.
Until now I just made tons of different tile maps for all the different mechanics. Spikes, new tile map. Jumping boost, new tile map.

Related

Effective way to make NavMeshAgents jump/climb obstacles in Unity?

So I'm working on a zombie game and I want my zombies to be able to climb/jump over certain obstacles around the map. I know that I can create nav mesh links to achieve this but when doing it it feels forced as the zombies will go to the link to connect the climb/jump instead of just going over the obstacle. I am having trouble in my research finding an effective way to do this.
Basically here is what I want to achieve:
1.) When a zombie reaches a certain obstacle (fence, car, crate, etc.) that is climbable, instead of running around the obstacle to get to the player I want the zombie to climb or jump over the obstacle.
2.) When the player climbs on top of an obstacle I want the zombies to also be able to climb on the obstacle to be able to attack the player.
Does anyone have suggestions on effective ways to go about this or possible methods I could further research? From the hours I've spent researching this I'm not having any luck finding something that goes with what I want to achieve.

How to reduce Huge Gaps Between Tiles in Platform tile map 2d Unity Grid?

Hello World, I am new to game development. Started making games using Udemy classes & free assets online. I am working on a platformer game, while trying to use tiles I find huge gaps between them. I experienced the same issue with tiles in Background layer, however I was able to solve that by reducing the Grid size from 1 to 0.75 on x,y,z axis respectively. Please advice

BuildNavMesh is too slow

NavMeshSurface.BuildNavMesh();
I want to do "Bake" of NavMesh dynamically. My game is like Minecraft.
I move the MOB around the world. Player can place blocks. So, if I do BuildNavMesh() I will be able to "Bake" NavMesh with new blocks.
Blocks is placed by the player. And every time player puts a block, I do BuildNavMesh(). Players can jump on them. Player can also destroy those blocks.
As I mentioned earlier, I do not know what to do other than that.
I can only write the above code.
NavMeshSurface.BuildNavMesh();
The best result I want is to use NavMesh to dynamically change the MOB's range of motion.
My navmesh was also building extremely slow. 2 things that really helped were:
play around with the tile size on the NavMeshSurface component, the smaller the faster it will build but it has some tradeoffs.
remove unnecessary layers from you NavMeshSurface component. And this was really the biggest issue. I had the default layer and ui layers in there which caused a big lag, removing them almost instantly rebuilds the navmesh in runtime!

How to Combine Vertices and edges into one In Unity

I'm new to Unity and I'm making a car racing Game. Now, I'm stuck at some point. I was looking for some solution of my problem, but couldn't succeed.
My problem is:
When I run my game on my phone, it sticks badly because whenever there are several buildings in front of the car camera, like one building behind another building, it lags. Reason for this is there are so many vertices and edges at that time, So the Car Camera is unable to capture all that stuff at same time.
How do I preload the 2nd Scene while loading 1st Scene?
I am using Unity free version.
In graphics programming, there is a common routine to simply don't draw objects that aren't in the field of view. I'm sure Unity can handle this. Check link: Unity description on this topic
I'm not hugely knowledgeable about Unity, but as a 3D modeller there's a bunch of things you can do to improve performance:
Create a simplified version of your buildings with fewer polygons for use when buildings are a long way away. A skyscraper, for example, can be as simple as a textured box.
If you've done that already, reduce the distance at which the simpler imposters are substituted for the complex versions.
Reduce the number of polygons by other means. A good example is if you've got a window ledge sticking out of the side of a building, don't try and make it an extension of the body. Instead, make it a separate box, delete the facet that won't be seen, and move it to intersect with the rest of the building.
Another good trick is to use bump maps or normal maps to approximate smaller features, rather than trying to model everything.
Opaqueness. Try not to have transparent windows in your buildings. It's computationally cheaper to make them just reflect the skybox or a suitably blurred reflection imposter. Also make sure that the material's shader is in Opaque mode, if it supports this.
You might also benefit a little from checking the 'Static' box on the game object, assuming that buildings aren't able to be moved (i.e. by smashing through them in a bulldozer).
Collision detection can also be a big drain. Be sure to use the simplest possible detection mesh you can - either a box, cylinder, sphere or a combination.

Controlling Player Movement After Per Pixel Collision

I have implemented a full per pixel collision system that accounts for rotation, and its very accurate. It returns a simple bool on collision.
However I am not sure how to handle the collision from the player movement point of view.
E.g. In the picture above, if the player is holding up on the left stick, he should be stopped, but if he is holding up + right diagonal on the left stick, he should slide northeast alongside the side of the red square almost naturally.
How do I go about this, to make the player’s momentum stop, but still give control for the player to move in direction not blocked by a collision.
I could do this kind of thing with simple untransformed rectangles, but going into per-pixel texture collision has made my brain explode today so I’m hoping you guys can help. Any advice would be massively appreciated.
It is possible. For that you need to implement physics engine with your pixel based collision if you are willing to give natural effect in your game.
For that either you write your own game engine or use engine that is already there. For 2D game I highly recommended Farseer Physics Engine. It is out there for a long time. Now in stable condition and it surely wonderful.
It is developed using XNA only from scratch, and also performance wise it is far good.
Have a look at this. I hope I was able to give you answer. Please let me know if more details needed.

Categories

Resources