Jump to content

Help with Entity Under Mouse


Recommended Posts

14 hours ago, PaulCiclops said:

Because when the client uses, receives the value of the mouse host

What do you want to do?

If you want to delete stuff, you can stand near the object to delete, and input (example, for evergreen prefab):

c_find("evergreen"):Remove()

 

Edited by DarkXero
Link to comment
Share on other sites

10 hours ago, DarkXero said:

What do you want to do?

If you want to delete stuff, you can stand near the object to delete, and input (example, for evergreen prefab):


c_find("evergreen"):Remove()

Another way, is using TheInput, but client side. You know how "Remote:" appears on the side of console? Press Ctrl to remove it.

Then input:


TheNet:SendRemoteExecute("Ents["..TheInput:GetWorldEntityUnderMouse().GUID.."]:Remove()", 0, 0)

To make the client send a custom crafted command (remove the entity with this GUID, after obtaining it with the mouse command).

I'm using it to pick up a target for a follower.

Does not work. Its show me how to use it to pick up an entity and save in a variable?

Edited by PaulCiclops
Link to comment
Share on other sites

5 hours ago, PaulCiclops said:

I'm using it to pick up a target for a follower.

c_find("follower").components.combat:SetTarget(c_find("target"))

With follower being your follower prefab, and target being the target prefab.

5 hours ago, PaulCiclops said:

Its show me how to use it to pick up an entity and save in a variable?

You can do:

c_select(c_find("target"))

to store a prefab as a debug entity, and then

c_sel()

will refer to the entity stored via c_select.

10 hours ago, Muche said:

I don't think GUIDs on the client are the same as on the server.

Yeah, I thought it did but it turns out it doesn't.

So your best bet with TheInput:GetWorldEntityUnderMouse() is to just send the position of the entity you selected and reselect it in the server.

Link to comment
Share on other sites

5 hours ago, DarkXero said:

c_find("follower").components.combat:SetTarget(c_find("target"))

With follower being your follower prefab, and target being the target prefab.

You can do:


c_select(c_find("target"))

to store a prefab as a debug entity, and then


c_sel()

will refer to the entity stored via c_select.

Yeah, I thought it did but it turns out it doesn't.

So your best bet with TheInput:GetWorldEntityUnderMouse() is to just send the position of the entity you selected and reselect it in the server.

This has helped me a lot, but needs to pass targets that do not contain the component "combat" like as trees and rocks. Because my pet can destroy these objects. How can I do this?

Link to comment
Share on other sites

1 hour ago, PaulCiclops said:

This has helped me a lot, but needs to pass targets that do not contain the component "combat" like as trees and rocks. Because my pet can destroy these objects. How can I do this?

I assume you gave your pet a brain with the "ChaseAndAttack" behaviour, which is why loading the target option of the combat component works. To make your pet react against other stuff, you need to improve your brain.

For example, like how the shadowwaxwellbrain does it.

Link to comment
Share on other sites

15 hours ago, DarkXero said:

I assume you gave your pet a brain with the "ChaseAndAttack" behaviour, which is why loading the target option of the combat component works. To make your pet react against other stuff, you need to improve your brain.

For example, like how the shadowwaxwellbrain does it.

Actually my pet has the ability to destroy things to touch. So are presciso a way to make him get up to entitidade, so he breaks it. How can I do this in an easy way? But I want to make him reach a specific and not the first to find, type in what I'm aiming or the mouse is over and has to run on the client and server.

Thank you in advance.

Edited by PaulCiclops
Link to comment
Share on other sites

15 minutes ago, PaulCiclops said:

But I want to make him reach a specific and not the first to find, type in what I'm aiming or the mouse is over and has to run on the client and server.

Instead of using (with FindEntity, that looks for the nearest entity)

local function FindEntityToWorkAction(inst, action, addtltags)
    local target = FindEntity(GetLeader(inst), SEE_WORK_DIST, nil, {action.id.."_workable"}, {"INLIMBO"}, addtltags)
    if target then
        return BufferedAction(inst, target, action) or nil
    end
end

you use something like

local function FindEntityToWorkAction(inst, action, addtltags)
    local target = inst.mouseloadedtarget
    if target then
        return BufferedAction(inst, target, action) or nil
    end
end

and then you load that variable.

c_find("follower").mouseloadedtarget = c_find("target")

Then the brain will go after it.

Link to comment
Share on other sites

23 hours ago, DarkXero said:

Instead of using (with FindEntity, that looks for the nearest entity)


local function FindEntityToWorkAction(inst, action, addtltags)
    local target = FindEntity(GetLeader(inst), SEE_WORK_DIST, nil, {action.id.."_workable"}, {"INLIMBO"}, addtltags)
    if target then
        return BufferedAction(inst, target, action) or nil
    end
end

you use something like


local function FindEntityToWorkAction(inst, action, addtltags)
    local target = inst.mouseloadedtarget
    if target then
        return BufferedAction(inst, target, action) or nil
    end
end

and then you load that variable.


c_find("follower").mouseloadedtarget = c_find("target")

Then the brain will go after it.

It worked, not the way I wanted but better than nothing. That parameter can go to find that fit into anything q can be destroyed, such as trees, rocks, buildings and others.

But thank you for the help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...