This is probably not what is typically called “aim assist,” but the goal is the same.
The player is moving a flying avatar around a 3D space, a room full of stuff. The camera follows the avatar. Much of the game play depends on knowing where the avatar is relative to the objects above and below it in the room. For example, dropping something onto an object requires the avatar be directly over the object. Or just avoiding certain obstacles. The greater the avatar’s altitude, the more difficult it is to determine a reasonably precise location without some additional cue(s).
I tried various light-based approaches to cast a shadow below the avatar, for example, using a spot light to cast a shadow or a cookie. There are problems with this, like keeping the shadow a constant size when the avatar changes altitude, or even getting a decent-looking shadow. What I’ve settled on for now is using a shadow object, a separate game object that looks like a shadow (transparent gray) and follows the avatar. The problem with this is that the “shadow” is always at floor level, which works great, but only if there is nothing below the avatar. When the avatar passes over an object, the shadow disappears under it. Varying the height of the shadow object looks totally unrealistic, as the entire shadow jumps up and down at edges.
I’m looking for suggestions on how to let the user know the x-y position of the avatar relative to its surroundings. Preferably something fairly subtle and non-intrusive, so as not to distract from what’s going on around. Thanks.
Hmm if you don’t need to solve the shadow problem but want an alternative, maybe install a camera under the avatar and have a screen you can slide in to see top down to the ground, maybe with a crosshair on it (google for bombing camera / bombing crosshair for examples).
Or the player can upgrade the avatar with an aiming laser guide, when you press a certain button, a laser pointer will point downwards to the exact hovering position.
Cant you simply adjust the altitude of the light accordingly? There is some ratio there. upon testing myself.
If the map geometry was spherical it may be possible to chase the object with a directional light.
I am adjusting the Y of the light above the UFO in the gif. It seems abit of TLC in that area’ will solve your problems with real shadow.
Aside this on the subject of fake shadows, I was going to suggest a small grid of shadows to help ease them them over those obstacles. but it might be quite tricky to pull off effectively.
I would use a shadow projector but don’t hang it on your player. Instead, raycast down to hit the floor, then lift the shadow projector up a certain constant distance (tune the cone and distance to suit you) and use Layers / LayerMask so the shadow does not impact your player.
In this game I use a projector that I move to the player’s position in LateUpdate() every frame. I think I also don’t let it get closer than 1 unit from the ground.
Yeah, if you’re not willing to use a separate object for the blob shadow due to stylistic reasons then a projector or decal are your best options I’d say.
Out of curiosity, how realistic does this need to be? I’ve used the raycast shadow-object method before and while it isn’t realistic it certainly never hurt the aesthetics of my games. Many famous games of the past used a similar method, for example, Mario64. So if it’s just a case of you noticing it because you know its there I’d say don’t worry about it and just go with that. No one will ever notice or care. On the other hand if you really are going for a much more convincingly realistic look then I can understand.
That’s one of the things I tried. I had an overhead view that could be turned on and off. It worked well for seeing the relative positions of obstacles. Only problem was, I never looked at it. I could see the shadow right below without having to look away from the action at the overhead view. I really liked the overhead view, and didn’t want to get rid of it, but I couldn’t make myself use it, and it obscured part of the screen. So it’s gone, but the code is still there, just in case.
I like the way your example works. What exactly is a “shadow projector?” Do you mean a light with something that casts a shadow in front of it? Or a light with a cookie? That’s what you’re moving with the player? I’m already moving my shadow object to follow the avatar, so this sounds like a pretty easy change.
THANKS! I’ve been using Unity since version 3, and never once came across the Projector effect. It’s similar to what I was trying to do unsuccessfully with a light & cookie. Learn something new every day.
The two Unity asset packages in the Asset Store that this link points to do not have any projector-related assets. I believe there used to be a menu option for importing the standard assets package, but I don’t see it there anymore. It doesn’t look like I can use a project without the special shader.
I found the shader on Github, created the textures according to the Unity Manual, and spent some time trying to get a projector working in my project without success. I thought maybe there was a problem with the scene having baked light maps, so I created a new, empty scene, and still had only limited success.
In the existing scene, the best I could do was some gray, amorphous shading that filled entire objects’ surfaces. In the empty project, I could at least see the shape of the shadow. But the shadow texture always completely fills whatever surface it touches. None of the settings (e.g., FOV, ortho size) have any effect, nor does the position or rotation of the projector. If it hits a surface, the shadow fills that surface.
I see a few warnings in the shader code, but it says they are fixed. Maybe that particular shader is no longer supported? (I know virtually nothing about shaders.) I’ve set things up just like the Manual says, I’ve tried every possible texture format and import setting, and every projector setting, and nothing makes a difference.
That did the trick! Thanks! This is exactly the effect I was looking for (now that it’s working). I can just replace my existing shadow object, which already moves and rotates with the player, with this. I like it when something turns out to be easier than expected :).
It was the shader I found on Github that was the problem. For future reference, DO NOT use or link to this shader: Github
I’ve noticed one bit of odd behavior from the projector that you can see in the attached screen shot. When the projector passes through a doorway, it projects upward (in the opposite direction). In this example, the projector is just below the top of the door opening, pointing downward, projecting onto the floor. Even though the projector is in empty space, in a hole cut out of the wall, it seems to think it is inside the wall.
The only solution I’ve found is to put walls with doorways (and windows) into a different layer. That’s not really an option as it would have a ripple effect on light map settings and other things. I could change the models, so there are no holes in walls, but that creates its own set of complications. I knew my optimism was premature.
Note to Unity: The projector is useless without the shader, and as far as I can tell, the shader is not available anywhere (at least not one that works). If not for the assistance I received here, I would not have been able to use this Unity feature. Please make this shader available again.
I just don’t see it orion. See below. It was never part of the standard shaders. It was included in the StandardAssets distro, which they updated for 2018 and simultaneously abandoned.
Unity actively PREVENTS people from downloading StandardAssets 2018 unless you already got it.
This to me is madness.
List below. (Edit: Yuk, I can’t seem to make it look good…)
List of shaders included in ‘standardshader’
7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)
Scanning the drive for archives:
1 file, 282295 bytes (276 KiB)
Listing archive: builtin_shaders-5.6.7f1.zip
–
Path = builtin_shaders-5.6.7f1.zip
Type = zip
Physical Size = 282295
Wow, okay. Thankfully I got it on asset store back then, it lets me redownload it. But honestly the whole thing with the huge backlog of unfinished projects and recent layoffs sounds like a complete disarray. Well, at least that explains the acquisitions – these were not investments in economic growth, but hunker-down securities.