Allthough I have several questions, and hoping for some answers back x)
At first, I bought the Unity pro license, to check it out, and Im really liking it, but as every noob, im not completely worked in yet with the scripting etc, allthough building is not the problem!
Now ill tell you bout my new lol-project to start testing it for real.
I have this, lets say ‘thing’ and I can move it around, blala, i have several coins on the map, but I want to be able to pick those up, then I can make a score system out of that, so that they disappear when picked up…
But the hard thing is, I want to create an RPG/RTS kinda style. which after lets say having 10 coins, I want to build something, like in an RTS, is this possible with Unity?
Also, any way of doing this. I tried looking stuff up for picking up, but all I can find is picking rigidbodys up, and like drop them somewhere else!
That is the first step, I would really appreciate help!
Thanks, and sorry for the trouble you put into reading and replying to this
Yes, the answer would be in the tutorial, but if you want to skip that (you should do it eventually…it is a great primer), set the colliders on your coins to triggers. Then you need to overload the coin’s OnTriggerEnter() function to:
1)update the player’s “score” directly (which I assume is just how much money they have), or have it call an accessor function in the player script (better practice) to update the score
2) then destroy the coin
To handle the building of buildings, you just need scripting that checks the cost of the building to be built against the player’s cash and, if the player has enough, execute the build functionality.
Wow, i really appreciate the answers, I am checking into the learnmesilly tutorials atm, and they are now gonna show me how to do this. otherwise ill do the 3d platform game from unity. Appreciate the help!
Have fun
and Oxl, lol about your comment, but im not gonna answer to that tho
I have succesfully did all the scripting bout collecting and putting it into the GUI etc.
And now the hardest part is coming, creating the RTS while playing the RPG method, I have been mailing with THE Will Goldstone from the Unity book etc.
And as expected, this is a hard piece of work.
If I can make it work, ofcurz I will share this with the rest of the Unity users, and even make a tutorial out of it, but I would like to have some feedback and maybe some help from other Unity users, to accomplish this.
The basic idea is, for example after collecting 10 coins, which is needed to create a “building”, you can press a button, which activated a new camera, from bigger zoom. So u get a “ghost” building to place on the map, But, I need the building to attach to the world I have created, and it must fit on the surface where its flat.
So that I can press it, and it IS there now. So after this, it activates the FPS camera again.
So what we want to create is:
"
i) Instantiation - you’ll need to instantiate a ‘ghost’ or different coloured version of your building the user can drag around
ii) Getting the model to follow terrain normals and verteces
iii) Using an orthographic mode camera
iv) Raycasting that follows the mouse in order to position things"
“quoted from Will”
If any Unity users feel like helping, we can help each other, to make scripts for following users, to make it easier for them!
I already have a script for everything except the ortho camera part. I actually have two scripts. One that only lets you place a building on a reasonably flat surface, where it will then orient itself to that surface (it’ll be properly vertical, but won’t sink halfway into the terrain on one end). Actually, it only let’s you place the building based on the maximum grade of the area of terrain. You can set the max allowable grade as you see fit.
The second version, which isn’t as good because it can sometimes require a higher resolution heightmap, will automatically flatten the terrain under the building before it places the building. The drawback of this one is that it does need a high resolution heightmap if the scale of your building is small relative to the terrain. However, with a higher res heightmap, the flattening of the terrain gets more expensive and there is a delay from when you click the button, and it flattens the ground and places the building. There is probably a way to optimize it, but I haven’t worked on it.
The ghost building will hover over the terrain (you chose the height at which it will hover) wherever your mouse is pointing and, when you click the button, it places it, replacing the ghost material with the proper material, assuming it is a valid location. The ghost is semi-transparent, and it is colored green when the terrain is suitable, and it turns red if the terrain is not suitable.
I am at work. When I get home tonight, I will post the scripts. They are raw and rough, but they work. If you run with them and get them clean, slick, and optimized, maybe you could shoot the new and improved versions back to me.
Wow, i totally liking this forum…
Please put them here, and if u find the time, pm them to me personal too.
And ofcurz. I will try to optimize them and post them back to you, as promised to Martin.
I will try to fix the camera script myself then, because I will need it more then 1ce, in some other ideas that are in my mind…
I appreciate the help!
Greetings, jNox
Here’s the main script. The script that levels the terrain is separate, and I never incorporated it. If you still want that one, let me know, but I think this will suit your needs.
In my project, I had a camera in a third-person mode, but looked down at the ground at about a 30 degree angle. It should work from any angle, from top-down to first person viewpoint.
Like I said, it’s rough and surely can be greatly improved, but it worked well enough to suit my needs. I commented it as best as I could. I know how frustrating it can be to try and decipher someone else’s code without documentation. Good luck with it.
EDIT: Oh, and you just place the script on whatever gameobject you want. I had an empty gameobject that held it. Not good practice, but I was only testing out the functionality of it anyway.
Lol apparently more people needed it, as I see the downloads, not nice of them to not post their idea’s.
Im currently reading true the script. it needs some tweaking yes, but its a very good base, which i recommand to other programmers, to help tweak a little, ill try to do that today!
Thanks, and good luck
ok, first thing is, since im doing an FPS/RPG.
Im trying to fade out the camera to another camera, which i found on the community page, If i get them together, and working fine, after button B pressed → Buy. I will post it here…
Good luck!
It’s no matter. It was a throw-away project. I was just doing it to see if I could make it work. If I thought it was in the condition to offer to the community at large, I would have done it anyway.
By the way, not sure if you need it for your game, but I also worked out RTS camera controls where you can either move the camera by moving it to a screen edge or by clicking on the terain and dragging it. Let me know if you are interested.
Lowl, this is getting epic, im just collecting scripts, and try optimizing and checking whats best for my project. so if u dont mind, you can allways share! atm, i cant optimize anything, since Unity is making my windows-pc crash… and I need to wait for my new Mac to arrive to optimize >.<
Ah well, thanks before anyway!
Hmm, I have been improving Maker16’s script, since im quit new, it wasnt easy.
First errors i occured was that the green object that he made of my prefab. that it only showed on 1 object, and couldnt see it anywhere else, still working on that, but also, if u clicked it only placed the object at 0,0,0 not at where your mousepointer is at, not the crosshair. So I added a raycasthit, together with Martin, so that if u click, the object in the variable will be created there!
Also have some If’s and Outputs in there for my project, so dont mind them…
Also the function doesnt work if the terrain is not flat, it wont place. so also working on that…
Have fun with it!
PS: i am adding the change view of camera, so that it will change to a second camera x)
i am a total noob at unity but have some experience with C. how about you create a plane and set its collider to a trigger , that way when it is above something that is not flat or there is not enough room, it will trigger a script.
I finished the script, there is one error with the vector 3, that it will refresh the box all time, because your mouse is on there. but i will try to fix that soon.
this is what i have now…
If u have any questions just ask, if u know something to update, just ask… >.<
This is awesome! Thank you so much for posting this. I’m just getting into Unity and am trying to put together as many proof of concepts I can to learn the engine. Keep up the good work!