unity – Model missed by both EventSystem.current.RaycastAll and IPointerClickHandler when scaling time

Update 3: I’ve found a workaround, but why the problem only manifests when scaling time still mystifies me.

Original post:

I have a situation where a model is ignored in favour of one behind it. The rear model is returned by EventSystem.current.RaycastAll, and the front model’s IPointerClickHandler callback isn’t triggered if the rear model is present. The rear model does not implement IPointerClickHandler (or pointer up/down handlers, etc). Both these things work on the front model if the rear model isn’t there.

Debugging shows that the Raycast is only returning one result. By comparing behaviour when the rear model is and isn’t present, I can verify that the distance value in the RaycastResult is greater when hitting the rear model than when hitting the front model.

I can “fix” the problem by using the Inspector to disable and re-enable the front model.

Here’s the problem and the “fix” in action:

Tooltips fixed by disabling and re-enabling an object

Higher quality version here.

EventSystem.current.RaycastAll is used to power the tooltips, and IPointerClickHandler is (unsurprisingly) used to get the cube model to react to clicks.

Update: After more investigation, I’ve made limited progress:

  • I’ve fixed the problem when running the game at normal speed by giving both objects a kinematic Rigidbody.
  • However, the problem still occurs when I speed up time. I set Time.timeScale, and increase Time.fixedDeltaTime by the same scale factor as recommended here.
  • I can eliminate the problem by not changing Time.fixedDeltaTime, however I’m reluctant to do so since this has a big impact on framerates at higher speeds (12x being the highest available).
  • If time is paused (i.e. Time.timeScale == 0) then the problem never fixes itself – time needs to be moving forward for the raycast to start hitting the cube. Presumably this is because physics calculations are suspended when time isn’t progressing.

enter image description here

Again, higher quality version here

Unity version: 2020.3.11f1

Update 2: As requested, here’s the raycast and time scaling code:

public class TooltipDisplay : MonoBehaviour {
    public void FixedUpdate() { // I've tried it in Update too, no change
        PointerEventData pointerData = new PointerEventData(EventSystem.current);
        pointerData.pointerId = -1;
        pointerData.position = Mouse.current.position.ReadValue();
        List<RaycastResult> results = new List<RaycastResult>();
        EventSystem.current.RaycastAll(pointerData, results);
        Tooltip highest = null;
        foreach (var result in results) {
            // There's only one result here, and it's often the wrong one :(
            Tooltip t = GetTooltip(result.gameObject);
            if (t == null) continue;
            if (highest == null || t.priority > highest.priority) {
                highest = t;
            }
        }
        // If we found a tooltip, display it.
        // ...
        // ...
    }
}


public class SpeedLimiter {
    
    private int multiplier;
    private static readonly float DEFAULT_FIXED_DELTA_TIME = Time.fixedDeltaTime;
    public const float SECONDS_PER_COMMAND = 2.0f;
    public float timeAccumulated { get; private set; }
    
    // Called from a Unity Button press (bottom-right of video) or from an Input system keypress handler.
    public void SetMultiplier(int speed) {
        multiplier = speed;
        Time.timeScale = multiplier;
        Time.fixedDeltaTime = DEFAULT_FIXED_DELTA_TIME * multiplier;
    }

    public bool Advance() { // Called in Update
        bool looped = false;
        timeAccumulated += Time.deltaTime;
        while (timeAccumulated >= SECONDS_PER_COMMAND) {
           timeAccumulated -= SECONDS_PER_COMMAND;
           looped = true;
        }
        return looped;
    }
}


public class UHexahedron : MonoBehaviour {
    Vector3 fromPosition;
    Vector2 toPosition;
    float translationStart;
    float translationDuration;
    bool translating;

    public void FixedUpdate() {
        if (translating) {
            float currentTime = SpeedLimited.timeAccumulated;
            if (currentTime < translationStart) return;
            if (currentTime >= translationStart + translationDuration) {
                Translate(1);
            }
            else {
                float lerp = (currentTime - translationStart) / translationDuration;
                Translate(lerp);
            }
        }
    }
    
    private void Translate(float lerp) {
        if (lerp >= 1) {
            transform.position = toPosition; // Tried rigidbody.position, no change
            translating = false;
            return;
        }
        transform.position = Vector3.lerp(fromPosition, toPosition, lerp); // Again, tried rigidbody.position, no change.
    }
}

Update 3:

It looks like part of the problem was that the PhysicsRaycaster on the main Camera had its maxRayIntersections set to 1. By increasing this I’ve managed to get the tooltips and click handling working, but it’s still unclear why this problem was only occurring when scaling fixedDeltaTime.

I started out by implementing a manual physics raycast alongside the EventSystem one in order to check that the raycasts were pointing at the correct things. I modified the TooltipDisplay code to look like this:

public class TooltipDisplay : MonoBehaviour {
    public void FixedUpdate() { // I've tried it in Update too, no change
        PointerEventData pointerData = new PointerEventData(EventSystem.current);
        pointerData.pointerId = -1;
        pointerData.position = Mouse.current.position.ReadValue();
        
        // EventSystem raycast
        List<RaycastResult> results = new List<RaycastResult>();
        EventSystem.current.RaycastAll(pointerData, results);
        Tooltip highest = null;
        foreach (var result in results) {
            // There's only one result here, and it's often the wrong one :(
            Tooltip t = GetTooltip(result.gameObject);
            if (t == null) continue;
            if (highest == null || t.priority > highest.priority) {
                highest = t;
            }
        }
        
        // Manual Physics raycast
        Ray ray = Camera.main.ScreenPointToRay(pointerData.position);
        RaycastHit() physicsResults = Physics.RaycastAll(ray, 100);
        Tooltip manual = null;
        foreach (var rh in physicsResults) {
            Tooltip t = GetTooltip(rh.transform.gameObject);
            if (t == null) {
                continue;
            }
            if (manual == null || t.priority > manual.priority) {
                manual = t;
            }
        }
        
        if (highest != null && manual != null) {
            highest = new Tooltip(
                highest.title + " / " + manual.title,
                highest.body,
                highest.priority
        }
        
        // If we found a tooltip, display it.
        // ...
        // ...
    }
}

This produced the following behaviour on-screen, where the right-hand half of the tooltip title was always correct, and the left-hand one lagged behind:

EventSystem raycast lagging behind Physics raycast

This led me to wonder whether the EventSystem raycast might be using the wrong camera. This wasn’t the problem, but searching around that brought me to this article which mentioned the limit on the PhysicsRaycaster and led me to the fix. I’ve increased maxRayIntersections and everything is now fine.

What remains unclear is why this problem only shows up when changing fixedDeltaTime.

So, although I now have a workaround, if anyone can work out why the original problem only showed up when scaling time, I’ll gladly award you the bounty.

unity – Model missed by both EventSystem.current.RaycastAll and IPointerClickHandler unless disabled and re-enabled in the Editor

I have a situation where a model is ignored in favour of one behind it. The rear model is returned by EventSystem.current.RaycastAll, and the front model’s IPointerClickHandler callback isn’t triggered if the rear model is present. The rear model does not implement IPointerClickHandler (or pointer up/down handlers, etc). Both these things work on the front model if the rear model isn’t there.

Debugging shows that the Raycast is only returning one result. By comparing behaviour when the rear model is and isn’t present, I can verify that the distance value in the RaycastResult is greater when hitting the rear model than when hitting the front model.

I can “fix” the problem by using the Inspector to disable and re-enable the front model.

Here’s the problem and the “fix” in action:

enter image description here

Higher quality version here.

EventSystem.current.RaycastAll is used to power the tooltips, and IPointerClickHandler is (unsurprisingly) used to get the cube model to react to clicks.

Unity version: 2020.3.11f1

Unity: Model missed by both EventSystem.current.RaycastAll and IPointerClickHandler unless disabled and re-enabled in the Editor

I have a situation where a model is ignored in favour of one behind it. The rear model is returned by EventSystem.current.RaycastAll, and the front model’s IPointerClickHandler callback isn’t triggered if the rear model is present. The rear model does not implement IPointerClickHandler (or pointer up/down handlers, etc). Both these things work on the front model if the rear model isn’t there.

Debugging shows that the Raycast is only returning one result. By comparing behaviour when the rear model is and isn’t present, I can verify that the distance value in the RaycastResult is greater when hitting the rear model than when hitting the front model.

I can “fix” the problem by using the Inspector to disable and re-enable the front model.

You can find a video of the problem and “fix” in action here: https://imgur.com/a/Oku79iB

EventSystem.current.RaycastAll is used to power the tooltips, and IPointerClickHandler is (unsurprisingly) used to get the cube model to react to clicks.

what I missed when writing a c# code from this pseudocode

what I missed when writing a c# code from this pseudocode – Code Review Stack Exchange

i missed my aliexpress delivery what do i do?

I got a voice message, in mandarin which was very inconvenient as my mandarin is pretty nonexistent, saying ‘no one was here to receive the package’ I believe. I have no idea what company was delivering my package and no idea if they are going to redeliver it again, so I’m not sure how to contact them. What do i do? I tried asking the seller but they just said ‘contact local shipping company’.

Configure advanced installer to ignore missed cab files and continue installation

I want to customize application installation and install some features based on existence of relevant cab file!

I want to use no custom feature selection dialog to show to user to select features!

How I can configure to install every cab file located next installer executable file without interrupting process due missed cab files! I am use Advanced Installer version 16.

altcoin – If my service only accepts Bitcoin, will there be a lot of missed customers who only have non-Bitcoin crypto currencies?

I’m about to release a service which only takes payments in Bitcoin.

I’m wondering if this will impact me negatively in terms of not getting business from people who own other crypto currencies.

I don’t reject the others out of ideological reasons, but for practical ones:

  1. My hard disks are already overflowing from the 335.8 GB Bitcoin blockchain.
  2. I barely trust Bitcoin Core to run on my computer — I don’t trust non-Bitcoin clients whatsoever.
  3. Even if I did have the storage space and the trust, I would have to learn the respective RPC APIs (assuming they exist) for each “altcoin” as well. It took me a very long time to grasp the Bitcoin Core API.
  4. Any kind of reliance on a third-party service is unthinkable due to KYC/AML BS, as well as the obvious risk with getting my money stolen if somebody else “holds them for me”.

Is there any way around this? Is there some kind of mega-trusted “multi-coin” client which doesn’t need to download the entire blockchains, yet is able to securely and locally handle multiple of the biggest altcoins, so that I could support those for payments?

Or would anyone who has altcoins also have Bitcoin? I get the feeling that they are very, very few, but perhaps they are also more likely to spend their coins compared to the stubborn “HOLDers” of the increasingly valuable Bitcoin?

I know myself that I’m very unwilling to part from any of my Bitcoin, especially as the price is increasing… It’s just a fact for me, but I can’t speak for others. I don’t have any other crypto currencies myself, and the times I’ve looked into them, I’ve just been put off by their software. (In the cases where software even exists!)

Advice?

dnd 5e – Can I replay an AL module with the same character to get a treasure I missed?

I was wondering about the rules on replaying an official D&D 5e Adventurer’s League module with the same character:

If I am willing to forgo taking anything with me during the initial session (ie, no xp, rewards, DT days, renown, gold etc), can I run it a second time with the same character?

The reason being that this is the only module in all three seasons that has a weapon my character is able to use, and I’d like a second chance at rolling for it.

web – Why has the Internet died? Is there some sort of new Internet that I’ve missed?

I send e-mails to mailing lists. No reply for weeks upon weeks. Dead.

I ask questions on Stack Exchange. No replies. Ignored. Just trolls and toxic people left.

I left freenode because every room was a ghost town in the last few years.

Every search query results in irrelevant garbage and/or eternal reCAPTCHAs.

Fake sites, registration forms that don’t do anything, “phone verification”, “upload photo id to load page”, etc.

The “dark web” doesn’t seem to actually exist at all. I do have Tor browser installed but there are no .onions to visit either.

Nothing seems to work. Nothing (worthwhile) seems to be used at all.

I’ve looked all over for some sort of “new Usenet”, but there is no such thing. All those decentralized projects are minimal and have zero users, in perpetuity.

I feel like I’m going insane. What has happened? How can there be far less activity on the Internet today than it was 30 years ago? How is that logically possible?

I might as well be offline completely. I basically feel like I am.

android 10 – How do I block “you missed a call from…” messages for blocked spam calls?

Android does a great job of blocking spam callers. However, my phone provider sends me messages when I miss calls, so while I don’t receive the spam calls themselves I always receive these follow-up sms in my inbox;

enter image description here

I don’t want to disable these SMS as they’re genuinely useful to receive when I miss calls from people I actually know. Also, clearly Android knows that this message is related to a spam caller, since it has flagged the message, so how can I get Android to just block these messages?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123