you hit the nail on the head with these tutorials, this is all i think anyone is ever looking for, the ground work, so many other tutorials go crazy with the information and it's just like "NO give me the basics" so thank you, this was perfect.
Woah, thank you so much! It means a lot, especially since I didn't know what I was doing when making these and I could probably make better tutorials now. This might motivate me to make some more, different tutorials. Have any ideas?
@@ludoremstudios could you please make a tutorial of selecting different towers with different stats info(each tower has own info and range) that would be really helpful since there's no tutorials on that
Thank you! If I ever find a new concept to make a tutorial on I will definitely do one, I just am at a lack for ideas on things that haven't already been done a bunch.
Man will you stop reading my mind? You're making this tutorial series EXACTLY when I'm trying to develop a game that needs this exact system. Thank you SO much, this is amazing! I'm not sure if you already covered this but I would be very interested in expanding this system with the possibility to change the height of the building pieces by holding down a certain key (most building games I played used the shift key)! But seriously, thanks again for your work so far!!
I have been waiting for a comment like yours! I am very glad you like it. An episode about expanding the controls would be great, but the lifting up is really all I have an idea for now. If you have any more ideas let me know.
Amazing tutorial. This series is exactly what I was looking for. I would be really happy if you would add another part where you will tell us how to rotate object automaticly when the object is not standing on a flat ground.
Thank you! I do know how to do that actually, but I thought it wasn't enough to make an entire video. I might make a youtube short going over how to do it in general but it wouldn't be specific to the building system, so you'd have to integrate it yourself probably.
You're making a great series on building, something rather hard to find. In one of your earlier videos where you handled rotation you said you might make a tutorial regarding smooth rotation (instead of 45° snaps), which I think would be appreciated. Other ideas for building tutorials: - How to snap buildings to other things, like perhaps a road, and/or other buildings, like you're doing with your golf course. (Perhaps I've just missed that part) - Upgrading buildings to a bigger/better version. - Building animation (the small bounce and particles in your golf courses). - Information about a building when selected. Cheers man, keep up the good work. Highly appreciated 👍
Hey! Thank you so much for watching and leaving a comment! About your suggestions: 1. I forgot about that, I might make another video soon covering that. 2. In MGT, the objects don't actually snap to each other, there is just a smooth grid. Sadly I don't really know how to do that, but even if I did figure it out I know its a lot of work. 3. Upgrading is something you can probably do yourself, just add another button to the select menu to upgrade something, and connect it to a method that changes the model of the selected object. 4. Animations and polish could come in the video with the smooth rotation, we'll see! 5. The info thing is something that requires you to use scriptable objects for each object, which isnt too hard to set up unless you already have a lot of objects. Simply instead of an array of game objects in the building manager, make it an array of a scriptable object called something like "BuildingData" (there are some good scriptable object tutorials already out there!). Use that building data scriptable to object to store the prefab that would be in the game object array, and access that for the building. And for the extra data, you are going to need a simple monobehaviour on each prefab that stores the corresponding scriptable object. In the SO, just add a string that stores more info, and set a new text object in the select UI to that string whenever you select something (by accessing the scriptable objects through GetComponent) This explanation was probably not very good, sorry. I might make a video on the scriptable object thing soon. So now I guess I have two potential videos: Polish & Scriptable Objects. Again, thank you so much for watching and your great suggestions.
Hey there, about the rotation. I added a new object reference like this: recentlyPlacedObject = pendingObject; pendingObject = null; And then added a slider in the UI with the rotation between 0 -360 that will calls this method: public void RotateObject(float rotation) { recentlyPlacedObject.transform.rotation = Quaternion.Euler(new Vector3(recentlyPlacedObject.transform.rotation.x, -rotation, recentlyPlacedObject.transform.rotation.z)); } There are more fancy ways of doing it, but this already works :)
I really love your tutorials! It's really simple and easy to follow compared to other tutorials I watched on RUclips. The only thing that I'm missing right now is gridlines. Is there any way I can somehow draw the gridlines?
Hey! Sorry for the late reply. I think the best bet would be to somehow make a shader using shader graph, because you can dynamically change the grid size that way. If you don't plan on changing the grid size on runtime, you can just make and scale your own texture, put it on a plane, and call that your grid.
Very nice tutorial! you made it so easy to follow. Btw, is there a way to spawn the UI at the current selected object's position? so that when i hit move button, the object's position won't deviate too much. Thanks!
There probably is! I think you could instantiate a canvas prefab with the UI on it as the child of the game object, but make sure that canvas is set to "world space" or something. That theoretically should work.
Hey man, great tutorial series so far. I now encountered a problem where I cant select my Buildings if im too far away. I dont think the length of the raycast is the problem because it seems like I can select all buildings if I enter some kind of "chunk". Its very very weird. You every had this problem? Thanks!
Hi, thanks for the great tutorial, do you know how to make the bottom of an object snap to the floor instead of its center? I've been scratching my head at this for a lil bit
Hey thanks for watching! If you are using a custom model made in Blender just move the object so that the bottom of the model is at 0 on the z, then apply the change with ctrl+a.
@@ludoremstudios thanks for that, just for anyone with the same issue-I'm using a asset pack of buildings by synty The reason that was happening is because grid snapping is on and the ground/terrain's position is not an number that the grid can snap to. For example my ground was -3.98...., but my grid snapping was set to 0.25. By setting it to -4 (or an increcrement aligning with the grid snap) it fixed it.
Oh boy i wrote a long comment but it dissappeared, but this tutorial was fantastic! Just wondering if i can have two different materials when objects are placed? I have a dither material on my walls and a regular on everything else (making a house building game). But just either one is showing..
Someone else has already asked this and I did provide a solution, so here you go: In your select object method in the building manager, after you have assigned the pending object, put this line of code: materials[2] = pendingObject.GetComponent().material; It should set the material to be the original material on the prefab when you first instantiate it. Thanks for watching!
8:30 - I'm having a error of using "BuildingManager" is this scode referring to my code I used to have the building mechanic or is a new Unity built-in varible I cant use on my version of Unity p.s love the videos, keep it up!
Thanks for watching! I answered your question in my Discord server. You need to reference the building manager in your GetComponent like so: GetComponent().
Hello! Nice Tutorial! I just have some issues maybe you can help. I'm using my own prefabs in the project and I wanna select them and delete too. I created empty selection object and used everything from your scripts (besides "outline" part, because my prefabs don't have it) and I can't move or delete my own prefabs, i added tags too... but nothing. Maybe you can tell me from where should I dig first?
I can't help you much without seeing your scripts. Using your own prefabs should be fine. Make sure they all have colliders and they have the correct layer and tags. Other than that I can't help without your scripts. It would be easiest if you join my discord server and post them there, but if you can't just paste your scripts here.
I could, but that one also uses a third party asset. And besides, in the next devlog you will see that I am remaking the entire building system... again. If I get enough requests I will.
Thank you! Shouldn't be too hard depending on what you are using for movement. NavMesh would simply be setting the navmesh agents target to an object, most likely from a list. You can use List.Add() when you place an object and List.Remove() when you delete one.
Yeah! Use EventSystem.IsPointerOverGameObject, and if it is true don't shoot the raycast for selecting. docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
I think this might have been in one of the tutorials, but in case you missed it, make sure to put something along the lines of pendingObj.name = objToSelect.name; in the SelectObject() method. I don't remember exactly how it's written, but basically you set the instantiated objects name to the prefabs name to remove it. There is another comment somewhere where this issue is discussed with probably a more accurate answer. Thank you for watching!
I used to use Blender (yes the 3D modeling software) but I recently switched to DaVinci Resolve. You can probably see the difference in quality. (I switched in I think devlog 12)
I haven't had any ideas on how to improve the series, and I am not sure what you mean by rotation and construction building system, I think the system already has that?
@@ZenoFar853 I think I see what you mean? Do you mean to have a ui button to rotate the objects? You could do that really easily, just make the rotate method public and call it with a button on click event.
If you are talking about what I have in Mini Golf Tycoon, that is simply an asset on the asset store called something like Runtime Transform Gizmos. It costs money though.
There is actually a slightly simpler solution. In the SelectObject() method (in the building manager, not the select manager), after you Instantiate the new object just set it's name to the prefabs name! Like pendingObject.name = objects[objectToSelect].name; (Some of the variable names might be off, I don't remember exactly). But thank you for sharing your solution!
This series not only helped me build a building system but helped me understand Unity as a whole a lot as well.
you hit the nail on the head with these tutorials, this is all i think anyone is ever looking for, the ground work, so many other tutorials go crazy with the information and it's just like "NO give me the basics" so thank you, this was perfect.
Woah, thank you so much! It means a lot, especially since I didn't know what I was doing when making these and I could probably make better tutorials now. This might motivate me to make some more, different tutorials. Have any ideas?
@@ludoremstudios could you please make a tutorial of selecting different towers with different stats info(each tower has own info and range) that would be really helpful since there's no tutorials on that
Helped me wrap my head around these concepts. Unity needs more tutorials presented exactly like this. Make more! :)
Thank you! If I ever find a new concept to make a tutorial on I will definitely do one, I just am at a lack for ideas on things that haven't already been done a bunch.
Man will you stop reading my mind? You're making this tutorial series EXACTLY when I'm trying to develop a game that needs this exact system. Thank you SO much, this is amazing!
I'm not sure if you already covered this but I would be very interested in expanding this system with the possibility to change the height of the building pieces by holding down a certain key (most building games I played used the shift key)!
But seriously, thanks again for your work so far!!
I have been waiting for a comment like yours! I am very glad you like it. An episode about expanding the controls would be great, but the lifting up is really all I have an idea for now. If you have any more ideas let me know.
Amazing tutorial. This series is exactly what I was looking for. I would be really happy if you would add another part where you will tell us how to rotate object automaticly when the object is not standing on a flat ground.
Thank you! I do know how to do that actually, but I thought it wasn't enough to make an entire video. I might make a youtube short going over how to do it in general but it wouldn't be specific to the building system, so you'd have to integrate it yourself probably.
You're making a great series on building, something rather hard to find.
In one of your earlier videos where you handled rotation you said you might make a tutorial regarding smooth rotation (instead of 45° snaps), which I think would be appreciated.
Other ideas for building tutorials:
- How to snap buildings to other things, like perhaps a road, and/or other buildings, like you're doing with your golf course. (Perhaps I've just missed that part)
- Upgrading buildings to a bigger/better version.
- Building animation (the small bounce and particles in your golf courses).
- Information about a building when selected.
Cheers man, keep up the good work. Highly appreciated 👍
Hey! Thank you so much for watching and leaving a comment!
About your suggestions:
1. I forgot about that, I might make another video soon covering that.
2. In MGT, the objects don't actually snap to each other, there is just a smooth grid. Sadly I don't really know how to do that, but even if I did figure it out I know its a lot of work.
3. Upgrading is something you can probably do yourself, just add another button to the select menu to upgrade something, and connect it to a method that changes the model of the selected object.
4. Animations and polish could come in the video with the smooth rotation, we'll see!
5. The info thing is something that requires you to use scriptable objects for each object, which isnt too hard to set up unless you already have a lot of objects. Simply instead of an array of game objects in the building manager, make it an array of a scriptable object called something like "BuildingData" (there are some good scriptable object tutorials already out there!). Use that building data scriptable to object to store the prefab that would be in the game object array, and access that for the building. And for the extra data, you are going to need a simple monobehaviour on each prefab that stores the corresponding scriptable object. In the SO, just add a string that stores more info, and set a new text object in the select UI to that string whenever you select something (by accessing the scriptable objects through GetComponent)
This explanation was probably not very good, sorry. I might make a video on the scriptable object thing soon. So now I guess I have two potential videos: Polish & Scriptable Objects.
Again, thank you so much for watching and your great suggestions.
Hey there, about the rotation.
I added a new object reference like this:
recentlyPlacedObject = pendingObject;
pendingObject = null;
And then added a slider in the UI with the rotation between 0 -360 that will calls this method:
public void RotateObject(float rotation)
{
recentlyPlacedObject.transform.rotation = Quaternion.Euler(new Vector3(recentlyPlacedObject.transform.rotation.x,
-rotation,
recentlyPlacedObject.transform.rotation.z));
}
There are more fancy ways of doing it, but this already works :)
Amazing series can't wait for the next one. Would be amazing if you could make a tutorial on how to snap on top of objects to create a roof
Thanks for the suggestion! It might not happen but I'll think about it.
Thank you for this, I'm new to Unity and this has helped me a lot. Would you consider a tutorial on building roads on a plane?
Perfect tutorial! Keep up the good work 😄
Thanks, will do!
hello can you help in one problem i have script related to building system this is problem when i place object or selected object object instantiate in ground not on ground this is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
public class BuildingManager : MonoBehaviour
{
public GameObject[] Objects;
public GameObject[] TempObjects;
public int[] ObjectsPrices;
public Material[] materials;
public TextMeshProUGUI WarningText;
public static GameObject PendingObject;
public static GameObject TempPendingObject;
private Vector3 Pos;
private RaycastHit raycastHit;
public ParticleSystem AfterPlaceEffect;
[SerializeField] private LayerMask PlacementLayerMask;
public float GridSize;
public float RotateAmount;
public float WarningShowTime;
public bool CanPlace = true;
private void FixedUpdate()
{
if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out raycastHit, 1000, PlacementLayerMask))
{
Pos = raycastHit.point;
}
}
}
public void Update()
{
if (PendingObject != null)
{
Pos = new Vector3(Grid(Pos.x), Grid(Pos.y), Grid(Pos.z));
PendingObject.transform.position = Pos;
TempPendingObject.transform.position = Pos;
if (Input.GetMouseButtonDown(0) && CanPlace == true && !EventSystem.current.IsPointerOverGameObject())
{
PlaceObject();
}
if (Input.GetKeyDown(KeyCode.R))
{
RotateObject();
}
}
if (PendingObject != null)
{
UpdataMetrials();
}
}
public void RotateObject()
{
PendingObject.transform.Rotate(Vector3.up, RotateAmount);
TempPendingObject.transform.Rotate(Vector3.up, RotateAmount);
}
public void SelectObject(int index)
{
if (PendingObject == null && PlayerMoney.playerMoney >= ObjectsPrices[index])
{
PendingObject = Instantiate(Objects[index], Pos, transform.rotation);
TempPendingObject = Instantiate(TempObjects[index], Pos, transform.rotation);
}
else if (PendingObject != null && PlayerMoney.playerMoney >= ObjectsPrices[index])
{
Destroy(PendingObject);
Destroy(TempPendingObject);
PendingObject = Instantiate(Objects[index], Pos, transform.rotation);
TempPendingObject = Instantiate(TempObjects[index], Pos, transform.rotation);
}
else
{
Debug.Log("Not Enough Money");
StartCoroutine(Warning());
}
}
public void DeselectObject()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Destroy(PendingObject);
Destroy(TempPendingObject);
PendingObject = null;
TempPendingObject = null;
}
}
public void PlaceObject()
{
GameObject ObjectToDestroy = TempPendingObject;
PendingObject = null;
TempPendingObject = null;
Destroy(ObjectToDestroy);
CanPlace = true;
}
public float Grid(float Pos)
{
float xDiff = Pos % GridSize;
Pos -= xDiff;
if (xDiff > (GridSize / 2))
{
Pos += GridSize;
}
return Pos;
}
public void UpdataMetrials()
{
if (CanPlace)
{
TempPendingObject.GetComponent().material = materials[0];
}
else
{
TempPendingObject.GetComponent().material = materials[1];
}
}
private IEnumerator Warning()
{
WarningText.gameObject.SetActive(true);
yield return new WaitForSeconds(WarningShowTime);
WarningText.gameObject.SetActive(false);
}
}
I really love your tutorials! It's really simple and easy to follow compared to other tutorials I watched on RUclips.
The only thing that I'm missing right now is gridlines. Is there any way I can somehow draw the gridlines?
Hey! Sorry for the late reply. I think the best bet would be to somehow make a shader using shader graph, because you can dynamically change the grid size that way. If you don't plan on changing the grid size on runtime, you can just make and scale your own texture, put it on a plane, and call that your grid.
Very nice tutorial! you made it so easy to follow.
Btw, is there a way to spawn the UI at the current selected object's position?
so that when i hit move button, the object's position won't deviate too much. Thanks!
There probably is! I think you could instantiate a canvas prefab with the UI on it as the child of the game object, but make sure that canvas is set to "world space" or something. That theoretically should work.
Where can I contact you sir? Your project is very nice. I love it!
Hey man, great tutorial series so far. I now encountered a problem where I cant select my Buildings if im too far away. I dont think the length of the raycast is the problem because it seems like I can select all buildings if I enter some kind of "chunk". Its very very weird. You every had this problem? Thanks!
No, I haven't ever seen this issue. My only guess is something with your canvas but I am not really sure. If you ever find a solution let me know!
Hi, thanks for the great tutorial, do you know how to make the bottom of an object snap to the floor instead of its center? I've been scratching my head at this for a lil bit
Hey thanks for watching! If you are using a custom model made in Blender just move the object so that the bottom of the model is at 0 on the z, then apply the change with ctrl+a.
@@ludoremstudios thanks for that, just for anyone with the same issue-I'm using a asset pack of buildings by synty
The reason that was happening is because grid snapping is on and the ground/terrain's position is not an number that the grid can snap to. For example my ground was -3.98...., but my grid snapping was set to 0.25. By setting it to -4 (or an increcrement aligning with the grid snap) it fixed it.
No funciona el boton mover, me pide que instancie un objeto, como podria resolver ese problema?
I would need to see your code and specific error, or else I don't really know what you mean.
Hi! Could you please do a video on how I could hold my mouse down and it will place loads of items so I don't have to keep clicking the button?
I will keep this in mind for the next tutorial, thank you! Not sure when it will come out though since I am really busy with other things right now.
@@ludoremstudios Thank you very much! Take your time :)
Oh boy i wrote a long comment but it dissappeared, but this tutorial was fantastic! Just wondering if i can have two different materials when objects are placed? I have a dither material on my walls and a regular on everything else (making a house building game). But just either one is showing..
Someone else has already asked this and I did provide a solution, so here you go:
In your select object method in the building manager, after you have assigned the pending object, put this line of code:
materials[2] = pendingObject.GetComponent().material;
It should set the material to be the original material on the prefab when you first instantiate it.
Thanks for watching!
@@ludoremstudios Thank you so much for replying! And thanks again for a great tutorial series. I hope you will make more similar ones :)
8:30 - I'm having a error of using "BuildingManager" is this scode referring to my code I used to have the building mechanic or is a new Unity built-in varible I cant use on my version of Unity
p.s love the videos, keep it up!
Thanks for watching! I answered your question in my Discord server. You need to reference the building manager in your GetComponent like so: GetComponent().
Thank you very much for your help.
Hello! Nice Tutorial! I just have some issues maybe you can help. I'm using my own prefabs in the project and I wanna select them and delete too. I created empty selection object and used everything from your scripts (besides "outline" part, because my prefabs don't have it) and I can't move or delete my own prefabs, i added tags too... but nothing. Maybe you can tell me from where should I dig first?
I can't help you much without seeing your scripts. Using your own prefabs should be fine. Make sure they all have colliders and they have the correct layer and tags. Other than that I can't help without your scripts. It would be easiest if you join my discord server and post them there, but if you can't just paste your scripts here.
@@ludoremstudios Thanks for collider info) It helps immediately :D
would you consider doing a tutorial on how you did your spline system in your Mini Golf Tycoon game?
I could, but that one also uses a third party asset. And besides, in the next devlog you will see that I am remaking the entire building system... again. If I get enough requests I will.
you are awesome!!!! it helped me a lot thank you
Simple and effective.Thank you. My next step is AI movement between created objects.
Thank you! Shouldn't be too hard depending on what you are using for movement. NavMesh would simply be setting the navmesh agents target to an object, most likely from a list. You can use List.Add() when you place an object and List.Remove() when you delete one.
Hey, great Tutorial,
Do you know how to make that if you click on a button and an object is behind that, the object doesnt get selected?
Yeah! Use EventSystem.IsPointerOverGameObject, and if it is true don't shoot the raycast for selecting.
docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
@@ludoremstudios thx
I am from Iran, you are wonderful
Thank you!
How to remove the (clone) from the objects?
I think this might have been in one of the tutorials, but in case you missed it, make sure to put something along the lines of
pendingObj.name = objToSelect.name;
in the SelectObject() method. I don't remember exactly how it's written, but basically you set the instantiated objects name to the prefabs name to remove it. There is another comment somewhere where this issue is discussed with probably a more accurate answer. Thank you for watching!
Quick question, what do you use to edit your RUclips videos?
I used to use Blender (yes the 3D modeling software) but I recently switched to DaVinci Resolve. You can probably see the difference in quality. (I switched in I think devlog 12)
Amazing tutorial!!!
Thank you!
for some resone the move and delete don't work
Make sure the UI events are set up properly!
@@ludoremstudios i have but the code doesnt work for some reason
@@ludoremstudios and another thing that is happenin' is that when I import a costume asset the code for selecting and deleting doesn't work
public void Move()
{
buildManager.pendingObject = selectedObject;
}
this is the code
tried to join your discord but it says i need to confirm im a human but it never gives the verification option
That means you need to verify your account with an email address or phone number.
Why u stop it please add rotate, and construction building system
I haven't had any ideas on how to improve the series, and I am not sure what you mean by rotation and construction building system, I think the system already has that?
@@ludoremstudios rotate the object u just added only move objects feature in this game there are rotate object feature too
@@ZenoFar853 I think I see what you mean? Do you mean to have a ui button to rotate the objects? You could do that really easily, just make the rotate method public and call it with a button on click event.
@@ludoremstudios I got it so can u add rotate and move with run time gizoms it will be amazing for this games category
If you are talking about what I have in Mini Golf Tycoon, that is simply an asset on the asset store called something like Runtime Transform Gizmos. It costs money though.
To Remove (Clone) from Instantiated Prefab Name:
public void SelectObject(int index)
{
pendingObject = Instantiate(objects[index], pos, transform.rotation);
pendingObject.name = objects[index].name;
}
Wheatley Crab
no
@@ludoremstudios yes
Subscribe
selectedObjectName.text = obj.name.Substring(0, obj.name.IndexOf('('));
For anyone looking for how to remove the '(clone)' from the name
There is actually a slightly simpler solution. In the SelectObject() method (in the building manager, not the select manager), after you Instantiate the new object just set it's name to the prefabs name! Like
pendingObject.name = objects[objectToSelect].name;
(Some of the variable names might be off, I don't remember exactly).
But thank you for sharing your solution!