Sign in to follow this  
Dryicefox

Multi-Character Interactions

Recommended Posts

Dryicefox    141

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

Share this post


Link to post
Share on other sites
BakaSchwarz    32

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.

Share this post


Link to post
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
Sign in to follow this