|
Post by gamifytheworld on Apr 18, 2018 8:12:14 GMT
Howdy,
Here's a little test video I put together with a dungeon level to test movement. There is some lagging in the video, but it's due to the recording software, not the game itself. I added some temporary audio to keep me in the mood while I'm working on it. Diablo was my favorite game of all time, and I'm building this to pay homage.
|
|
|
Post by uberwiggett on Apr 18, 2018 8:53:16 GMT
cool! can I ask what you did to get the transparent objects?
|
|
|
Post by gamifytheworld on Apr 18, 2018 17:12:41 GMT
Thanks!
I'm using a script on the camera that does a raycast and looks to see if an object is on a given layer ("hideable") and fade the object in and out using the Unity transparent\diffuse shader and iTween. I found the script on the internet a while back and just tweaked it for my prototyping needs.
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class HideObscured : MonoBehaviour { public GameObject player; public Shader shaderDiffuse; public Shader shaderTransparent; public float targetAlpha; public float time; public GameObject o; public bool mustFadeBack = false;
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); shaderDiffuse = Shader.Find("Diffuse"); shaderTransparent = Shader.Find("Transparent/Diffuse"); }
// Update is called once per frame void Update() { RaycastHit hit;
if (Physics.Raycast(transform.position, player.transform.position - transform.position, out hit, 30)) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Hideable")) { mustFadeBack = true;
if (hit.collider.gameObject != o && o != null) { FadeUp(o); }
o = hit.collider.gameObject;
if (o.GetComponent<Renderer>().material.shader != shaderTransparent) { o.GetComponent<Renderer>().material.shader = shaderTransparent; Color k = o.GetComponent<Renderer>().material.color; k.a = 0.5f; o.GetComponent<Renderer>().material.color = k; }
FadeDown(o); } else { if (mustFadeBack) { mustFadeBack = false; FadeUp(o); } } } }
void FadeUp(GameObject f) { iTween.FadeTo(f, iTween.Hash("alpha", 1, "time", time, "oncomplete", "SetDiffuseShading", "oncompletetarget", this.gameObject, "oncompleteparams", f)); }
void FadeDown(GameObject f) { iTween.FadeTo(f, iTween.Hash("alpha", targetAlpha, "time", time)); }
void SetDiffuseShading(GameObject f) { if (f.GetComponent<Renderer>().material.color.a == 1) { f.GetComponent<Renderer>().material.shader = shaderDiffuse; } }
void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawRay(transform.position, player.transform.position - transform.position); } } Just add it to your third person camera and set the target alpha to 0.25 and the time (fade in/out) to 0.05 to get the settings I used. Then you can tweak it as needed. The script isn't production ready as I need to build in the ability to hide object groups in a parent/child relationship and I'm thinking of using scriptable objects to query the objects properties instead of layers so that I can reserve layers for other purposes.
Let me know if you have any questions.
|
|
|
Post by gamifytheworld on Apr 18, 2018 17:17:53 GMT
PS, I think I posted this in the wrong thread. I was intending to post in the feedback thread and instead I accidentally hijacked the Invector showcase thread. Mods feel free to move this if you want. Sorry about that.
|
|
|
Post by gamifytheworld on Apr 18, 2018 20:49:58 GMT
cool! can I ask what you did to get the transparent objects? Hey, I've been following your work on the RPG work you are doing on YouTube and I'd like to engage you on some stuff I'm working on if you are interested. Perhaps a bit of collaboration could be had. Judging your accent, I'm going to guess we work different hours (I'm in Seattle, WA), but let me know if you are interested.
|
|
|
Post by uberwiggett on Apr 19, 2018 8:29:43 GMT
hey thanks for the replies! cool stuff, yeah I use a no deprecated asset that does the same thing as your script with a little bit more option toggles, but looks pretty similar so I was like wow you have it too? Thanks for posting your script, it's a really neat effect that I think a lot of people working on top down games would be grateful for. I'm close to releasing a game (hoping this weekend) and then I will be back on my RPG tutorial series, but I'd be happy to help out with anything you need when I can. And yeah I'm from Australia and I work full time, the best time to get me is over the weekends when i can stay up late at night
|
|
|
Post by gamifytheworld on Apr 19, 2018 22:09:46 GMT
Yeah, it sounds like we both are in similar situations. I'm a full time dev (have been a software engineer for 25+ years) and unless I want to go on no sleep, it's usually reserved for the weekends when I get to work on my games. Let me know when you get your game released. Then we can chat.
|
|
|
Post by gamifytheworld on Apr 19, 2018 22:20:10 GMT
Once I beef up the hide-able script to work with object groups and put a bunch more options in it, I'll share it. For now, it was just a quick and dirty way to prototype my proof of concept work. I have a bunch of stuff like that.
I'm focused right now on a better inventory system along with managing stats/attributes, dialogue, skill-trees, and quests. I find that the available assets on the store are too big and very heavy-handed in their approach. They seem to take over too many things in the project and end up becoming more of a hindrance making them work with other libraries. My plan is to make it an open-source project that is easy to setup, can bolt onto any asset, and provide some sample scenes on how to use it. I also have a new mini-map component that I'm working on that doesn't use the standard approaches that other people are using from the basic tutorials.
|
|