Forum rules - please read before posting.

trouble with rotating movable

The AC1.74 changed rotating and reactions with hotspots. I had a system in which player can rotate objects with hotspots. Rotating also activates hotspot if it's on the rotating object, witch is not desired, but can live with. But now player can't rotate if there's a mesh hotspot on a rotatable or if a player tries to rotate and hits a hotspot first.

Is there a way to fix this?

Comments

  • edited September 2021

    player can't rotate if there's a mesh hotspot on a rotatable

    This is when clicking on the Draggable, and not the Hotspot?

    How are your Hotspots and Colliders and Moveable_Drag components arranged relative to one another. Please share images that show full details.

    or if a player tries to rotate and hits a hotspot first

    If the Player clicks a Hotspot that has a defined Interaction, the interaction should run. You can disable the interaction if you don't intend for it to be interactable at a given time, but this behaviour was the same in previous versions.

  • Here's some pics:
    A cup with an object inside:
    https://imgur.com/JDgFFec
    The hotspot inside doesn't activate, collider is the same mesh.

    Object has separate hotspots:
    https://imgur.com/UxhYjsz
    https://imgur.com/OXIlwsQ
    I would also like it to have a main hotspot for the main mesh.

    I was wondering if I could capture the mouse point click before the grab and cancel the grab is mouse button is released before 200mils. And then fire a ray to select first hotspot and activate it.

  • Actually, if I just change here the preselected hotspot to ray and go from there, it may just be what I need...

    void OnDropMoveable (DragBase dragBase)
    {
        if (dragBase == draggable)
        {
            if ((Time.time - grabTime) <= maxTimeForHotspotClick)
            {
                hotspot.useButtons[0].interaction.Interact ();
            }
        }
    }
    
    void OnGrabMoveable (DragBase dragBase)
    {
        if (dragBase == draggable)
        {
            grabTime = Time.time;
        }
    }´
    
  • And add a check if another inventory object is selected for interaction, I could have like a screw driver interacting with screw.

  • Something turns some child objects layers to ignore raycast . Does AC do this?

  • add a check if another inventory object is selected for interaction, I could have like a screw driver interacting with screw.

    You can check the currently selected item with:

    KickStarter.runtimeInventory.SelectedItem
    

    Something turns some child objects layers to ignore raycast . Does AC do this?

    Hotspots and Moveable objects are placed on the "Deactivated" layer (by default this is Ignore Raycast, and configurable in the Settings Manager) when turned off.

    A Draggable's children will also be affected if Place children on same layer? is checked on the object's Inspector.

  • Is it possible to catch the hotspot action before it activates? And then activate grabbing of a movable?

  • The biggest problem here is that player can't see hotspots - or the cursor changes - if the hotspots are not enabled, and if hotspots are on, they take the input.

    One thing would be to set the object close ups to have an extra ray call for mouse move and detect disabled hotspots separate from AC core and then change the cursor, but I don't know if it would be a good idea in long run.

  • The OnHotspotSelect event will be triggered if the player mouse-overs a Hotspot, which needs to occur before it can be run. OnHotspotInteract will be run even if the Hotspot has no Interaction ActionList assigned.

    If you're looking to have the whole draggable run an interaction when clicked, without dragging, though, you could consider unsetting your Hotspot's Interaction ActionList and run it manually. If a Hotspot has a "Use" interaction defined, but without an Interaction ActionList assigned, it will still display an icon/label but have no click behaviour. Your code above could then be adapted to something like:

    public ActionList actionListOnClick;
    
    void OnDropMoveable (DragBase dragBase)
    {
        if (dragBase == draggable)
        {
            if ((Time.time - grabTime) <= maxTimeForHotspotClick)
            {
                actionListOnClick.Interact ();
            }
        }
    }
    
    void OnGrabMoveable (DragBase dragBase)
    {
        if (dragBase == draggable)
        {
            grabTime = Time.time;
        }
    }
    
  • Almost everything seems to work fine now! All objects rotate nicely and I created a script with a list of ALs corresponding to the different hotspots.

    There is still one thing. I have a cup with a ball in it. I can't seem to get the hotspot in it to react without turning convex off from the cup. And then the cup won't react.

    Is there any other way other then to create a hotspot for a thing inside cup large enough to come outside of the cup from the top?

  • A Hotspot's "clickable area" is bound by the collider attached. This doesn't need to match the shape of the visiable object - if you use a Box Collider for example, you can extend the regions of it to extend out over the top of the cup.

    This might cause problems with it being interactive when not visible, though - e.g. when viewed from the side. In that case, you'd have to look into turning the Hotspot on/off through script based on the rotation that the cup is facing relative to the camera.

    This is probably most easily done by checking the dot product of its relative position vs facing direction, i.e.:

    Vector3 cupFacingDirection = cupTransform.up; // Might need to change this to .right or .forward
    Vector3 cupRelativePosition = (KickStarter.CameraMainTransform.position - cupTransform.position).normalized;
    float dotProduct = Vector3.Dot (cupRelativePosition, cupFacingDirection);
    if (dotProduct > 0.5f) // Some threshold
    {
        ballHotspot.TurnOn ();
    }
    else
    {
        ballHotspot.TurnOff ();
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.