How to make a hexagonal shaped "plane" in Unity - c#

So i have already asked about this on the unity forums but i thought i'd ask here too.
Basically i want to create a hexagonal shaped plane object to create terrains, however the "plane" gameobject is square, could anyone point me in the right direction of how to do this?
Thanks in advance

find any hexa plane.obj or even .fbx online , or create it by any builder asset or using unity pro builder.
here is a hexagon.obj
https://drive.google.com/file/d/1K32bE6Kb22u3rt2hl3zoAuqUOvCZlT-r/view?usp=sharing

You can use Unity's Pro Builder Asset to create custom meshes for your game.
Here is some information about it: https://unity3d.com/unity/features/worldbuilding/probuilder

You have a few options....
First of all, does it have to be hexagonal, or just look hexagonal?
You could potentially use a texture with alpha transparency to make it appear hexagonal (although it would still be a full plane for all practical purposes, eg colliders).
Short of that, you need to create a custom mesh (model).
Again, there are lots of ways you can approach this. It's possible to do from inside Unity using code. This is very flexible, but pretty advanced.
Much simpler for now would be to use an external modelling tool (Blender is free and highly thought of).
Whatever you pick, it will almost certainly have a Polygon circle command that will allow you to specify how many points it should use.
Simply enter 6 here and you'll get a perfect hexagon.
Save as .fbx somewhere in your unity project. Unity will import the model and you can then drag it into your scene.

Related

Making objects smoothly meld into one another in Unity, using Shader Graph or similar?

I'm looking for a way to make two objects smoothly merge together in Unity. I'd like to do it through shaders rather than mesh, thinking that'll be faster as this merging effect needs to happen often at runtime. Initially I looked into raymarching as I saw an example of exactly what I'm looking for using it, see below. However, it seemed far too daunting a task to make raymarching from scratch and in general coding shaders in Unity. C# scripts I can manage but shaders seem like a whole 'nother beast.
Image of spheres merged together using raymarching
Or this link: https://i.stack.imgur.com/yYqHb.png
Link to the video tutorial the image is from
Or this link: https://www.youtube.com/watch?v=B1Rzst89MPU
(Thanks Stefan Wuebbe for reminding me to add clean links as well)
I am hoping to find a solution using Unity Shader Graph, as that's the only real shader work I've had any experience with. But of course, any suggestions for an approach to this challenge are appreciated.
For a bit more context, I am hoping to use these merging shapes to make dynamic elemental attacks and effects for a game about bending the elements I'm starting to work on. Specifically spheres merging could make a great effect for a water stream attack.
Thanks for the help in advance!

Control shadows in Unity

I find a way to control shadows: colors, shapes, intensity. I googled it before and had found that I can use custom pass or must write shader. But it seems difficult for me. Is there way to do it in shader graph? Or I must start to study HLSL?
Could you give me a right direction how I can study it?
In the basic sense of configuring shadows, you will need to combine light casting into the scene and the Mesh Renderer. There is also a whole section in Unity in the Mesh Renderer where you can configure the lighting scale, parameters and baking vs real-time rendering. Just like real life, focus on the lighting for the shadows to be the way you want them.
Unless you mean shaders of materials, since you mentioned passing. For that, you can look on the official Unity manual.

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.

How to create side scrollable 2d terrain in unity?

Hi iam trying to build a game in which the skater will skate on the irregular terrain which is 2D and side scrolling. Iam not getting how to instantiate a terrain dynamically and in different shapes along x-axis.. I want to achieve something like this http://thegoldenmule.com/labs/TerramorphicGenesisAlgorithms/. Please help.
Assuming you're referring to the 'circle hill' setting on the demo you linked, here's what I'd try:
Step 1: generate some nice 1D noise. My guess is the linked demo is only using two octaves, so I'd start with that. These points will end up being spread apart when you generate pixels for the actual line. It looks like the linked demo had them about 50 pixels apart.
Step 2: use spline interpolation to get values between the points generated in step 1.
To get a sense of how this works, try this demo (make sure to change the setting to cubic spline though). You'll probably need to experiment with the parameters of step 1. My hunch is you'll want to avoid noise that it too erratic & you'll need to space the resulting points out a bit. Something like this:
Alternatively, when I was looking for a spline demo/library, I came across Curvy - it might provide what you want & save you the time of rolling your own code. If not, there are probably other spline libraries out there that might work.
I spent quite awhile looking for this and couldn't find much. I finally decided to create my own solution - if you are trying to accomplish this in Unity, I created an asset which will do this for you. For some of the theory behind it, Prime 31 has a good youtube video that explains the general approach to take.
Try this asset from unity asset store.
This is very small, easy to use. Although graphics is pretty bad, you can put some shader or pp effect.

XNA 2d arcade game sprite follow

I am going to make a game like XNA example game "Platformer1" which comes with the XNA. But I need longer levels which doesn't fit in the screen (like Super Mario levels). How can I manage this kind of level? Do I need to use a 2d camera that follows the sprite? If I do this way how can I load the level? I am a bit confused and I am not sure if I could explain my problem clearly. Hope someone can help?
The tutorial based on Platformer Starter Kit in MSDN has a step Adding a Scrolling Level which guides you through creation of longer levels. The tutorial is very detailed, I highly recommend it.
I couldn't find the tutorial in the section for XNA Game Studio 4.0, but differences should be minimal. According to the comment at the bottom of the page, all you need to change is replace
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, cameraTransform);
with
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, cameraTransform);
in the tutorial code.
If you want to create a side scrolling game, then I would look into parallax scrolling. A quick google/bing will help you find lots of tutorials. Also, another useful tip is to search YouTube for XNA videos has we a lot of posters share their source code .
Here is a link to Microsofts Parallax Scrolling.
Sounds like you have a few problems ahead of you.
But I need longer levels which doest'n fit in the screen(like super mario levels). How can I manage this kind of levels.
There are several ways to do this, but a fairly easy way would be to have a 2d array (or sparse array, depending on how large your levels are) of a class named Tile that stores info about the tile image, animation, ...whatever.
Yes, you'll probably want a "camera". This can be as simple as only drawing a certain range of that array or a more featured camera that uses transforms to zoom out and translate across your level.
Hopefully this will help get you started.
I've done a decent amount of work in XNA, and from my experience, there are 2 ways to draw a 2D scene:
1) Strictly 2D. This method is much easier, but has a few limitations. There is no "camera" per se, what you do is move everything underneath the fixed 2D "camera". I say "camera" in quotes because the camera is fixed (as far as I know). The upside is that it's easy, the downside is that you can't easily zoom in or out or do other camera effects.
2) 2D in 3D. Set up a 3D world with a 2D plane. This is more flexible, but is also more challenging to work with because you will need to set up a 3D world and 3D camera. If this is your first attempt with making a game, I would highly recommend against this method.
I'm really only familiar with the strictly 2D method, and you would want a list of map objects that have a 2D coordinate. You would also want to store which section of the map you are looking at, I do this with a Rectangle or Vector2 that stores this. This value would move forward as the character moves. You can then take your 2D map objects' coordinate and subtract the (X,Y) of the top-left of what you are looking at to determine an object's screen position. So:
float screenX = myMapObject.X - focusPoint.X;
float screenY = myMapObject.Y - focusPoint.Y;
An other thing to note, use floats or Vector2/3 to store locations, you may not think it's required now, but it will be down the line.
It might be overkill, but my SF project uses XNA to draw a Strictly 2D scene that you can move around: http://sourceforge.net/projects/asteroidoutpost/
I hope this helps.
Have a look at Nick Gravelyns tutorials. They helped me tonne when I was first starting out - Really really worth a look for learning a lot on 2D games.
All the videos are now on youtube here

Categories

Resources