Author Topic: Footprints in code  (Read 552 times)

Dr.Fragg

  • Guest
Footprints in code
« on: May 11, 2020, 08:40:34 AM »
Hi,
I just purchased this yesterday, and it's looking way nicer than other fullscreen effects I've tried so far. The one problem I'm having though is stamping footprints for a top-down game. I've tried setting it to my character's position rather than the camera's, using a raycast for ground-check. I can see in the debugger that it Blits it, but I'm not getting any footprints. Any idea what I may be doing wrong?

Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Footprints in code
« Reply #1 on: May 11, 2020, 10:53:30 AM »
Hi,

Currently the snow footprints are designed for the FPS camera, because they stamp a two-feet texture just below the camera. From a third person perspective, it could result in a strange effect since the feet marks won't be aligned with your character's feet.

However you can create snow marks. A mark is a depression in the snow at any number of positions and custom radius. Make sure you have "Snow Marks" enabled in the inspector and use this code as an example in Update():

Code
            if (Input.GetKeyDown(KeyCode.Space)) {
                Camera cam = Camera.main;
                RaycastHit hit;
                if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit)) {
                    GlobalSnow.instance.MarkSnowAt(hit.point, 3f);
                }
            }

Dr.Fragg

  • Guest
Re: Footprints in code
« Reply #2 on: May 11, 2020, 12:11:15 PM »
Hi,

I had tried that earlier, and that did work...but I couldn't get any footprints to show up at all. If I can get them to appear, I don't mind tweaking their orientation as needed.
Shouldn't I be able to see footprints if I set the _WorldPos to a position I specify, instead of the camera position it's currently using for rendering FPS footprints?

Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Footprints in code
« Reply #3 on: May 11, 2020, 01:16:31 PM »
I understand you have the footprints option enabled in the inspector? They should appear, yes.
Can you post the code you're using? Which specific changes are you trying?

Dr.Fragg

  • Guest
Re: Footprints in code
« Reply #4 on: May 11, 2020, 01:27:52 PM »
Yes, they're enabled, and "active" is checked in the inspector as well.

I'm just trying to use the RenderFootprints function, but supplying my own position to draw to:
Code
public void RenderFootprints(Vector3 footPrintPosition)
        {
            if (footprintTexture == null || footprintTexture2 == null)
            {
                footprintTexture = new RenderTexture(FOOTPRINT_TEXTURE_RESOLUTION, FOOTPRINT_TEXTURE_RESOLUTION, 0, RenderTextureFormat.ARGBFloat);
                footprintTexture.filterMode = FilterMode.Point;
                footprintTexture.wrapMode = TextureWrapMode.Repeat;
                footprintTexture.hideFlags = HideFlags.DontSave;
                footprintTexture2 = new RenderTexture(FOOTPRINT_TEXTURE_RESOLUTION, FOOTPRINT_TEXTURE_RESOLUTION, 0, RenderTextureFormat.ARGBFloat);
                footprintTexture2.filterMode = FilterMode.Point;
                footprintTexture2.wrapMode = TextureWrapMode.Repeat;
                footprintTexture2.hideFlags = HideFlags.DontSave;
                Shader.SetGlobalTexture("_GS_FootprintTex", footprintTexture2);
            }
            Vector3 targetPos = footPrintPosition;

instead of targetPos being the camera's position.


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Footprints in code
« Reply #5 on: May 12, 2020, 12:45:40 AM »
Latest beta now exposes a new FootprintAt(position, dir) method.
Please send me your username and invoice number to grant you access to it. Thank you.

Dr.Fragg

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Footprints in code
« Reply #6 on: May 12, 2020, 05:05:49 AM »
Awesome, you rock! Sent you a PM.

Dr.Fragg

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Footprints in code
« Reply #7 on: May 12, 2020, 12:55:46 PM »
That works great, thanks! I think I found my initial problem...during my experimentation, I had set my obscurance to .05, thinking that should be less obscurance/more footprint, and they were just too light to see :-/. I should have re-read the tooltip.

Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Re: Footprints in code
« Reply #8 on: May 12, 2020, 01:45:58 PM »
Great :)