Jump to content

Multi-Character Interactions


Recommended Posts

Alright, so a friend and I are working on a character that is able to "store" another character in them. We are essentially making an action that sets the affected character's location to the location of the affecting character, and also sets their anim build to an "invisible" build.

My method of thinking is to create an action that sets a tag on the affected character "stored" to ensure that the character cannot be "stored" twice

Function "onstored"
     that sets the affected character's anim build to invisible, sets their location to that of the acting character, and strips them of their actions
Function "onunstored"
     that sets the affected character's anim build back to the target's original anim build and gives them their autonomy back.

My main problem is finding a way to code a target object that refers to the affected user.

 

Edited by Dryicefox
Link to comment
Share on other sites

Ah, okay. In that case you may want to look at playercontroller.lua.

You could add your code to the OnLeftClick function like so:

AddClassPostConstruct("components/playercontroller", function(self)
    local oldleftclickfn = self.OnLeftClick
    self.OnLeftClick = function(self, down)
        -- Your code here
        oldleftclickfn(self, down)
    end
end)

In your code you check that the currently played character is your character. Get yourself the ThePlayer variable and check its prefab.

Does this go in the direction you intended?

I am not sure the playercontroller is networked as is though. Never needed to do stuff with it. Maybe someone else can say more about this.

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...