Author Topic: SpriteBase.inputs  (Read 2319 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
SpriteBase.inputs
« on: 2012-02-11, 04:53:54 PM »
Ok, in a game I was working on, an original System I used was Creating a TargetBox Sprite, creating arms, legs, and limbs within that, then having the TargetBox sprite sending a PlayerNumber to all the Arms, legs, and limbs it contains.

Voila, a bone animated human sprite.

It worked great for a Non-Internet game.
But when I have a sprite controlled by a remote user, (Networking and such) It seems that the limbs don't respond. The player moves, jumps etc., but the arms and legs however, don't.

So I looked within SpriteBase, and I seem to have found 'inputs'- which contains the current sprite's inputs.

My question really is, is there a way to send this.inputs to another sprite's that.inputs within this sprite's collision mask/rectangle?
I'm not sure if I can send it as a parameter- or can it in some way?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SpriteBase.inputs
« Reply #1 on: 2012-02-11, 07:44:36 PM »
Why can't you set the inputs of those sprites for remote players the same way you do for local players, just map the same remote player to all the pieces?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SpriteBase.inputs
« Reply #2 on: 2012-02-12, 12:58:02 AM »
My code sends the inputs directly to the sprite.

Read NetData containing Input change
Give NetData to TargetBox
TargetBox interprets inputs from NetData- then sets the given inputs on itself.

The limbs aren't given anything.- I don't know if it's because I have to setinputs for a global object representing Player 4, but I can't give every single limb the NetData- it would cause too much of a Game Delay.

If there isn't a simple way, it's alright. I do have a time consuming way to do this..- but I hoped there was a faster way. :/

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SpriteBase.inputs
« Reply #3 on: 2012-02-12, 06:55:40 AM »
The player object was designed to collect the inputs once so that you can map the same inputs to any number of sprites without any extra "bandwidth" for re-reading the inputs.  You don't have to pass NetData to every limb, you just have to MapPlayerToInputs on every limb and pass NetData to the player.  If I were designing this (and I think NetSample demonstrates this), I would have designed the sprites to not care where their input is coming from.  They just take input from a player and it's up to the player object to collect the inputs.  Some of the player objects may represent keyboard inputs and others may represent network inputs.  But by separating the sprites from the network code, you don't have to care about network at the sprite level, only at the player level.  Is that an idea that could fit into your design still?

Think about it this way: All your TargetBox code that deals with anything having to do with the network should be moved into the player object, and then the TargetBox sprites (or limb sprites) can simply retrieve their data from the player object with MapPlayerToInputs (or a custom MapPlayerToSprite if you want to transfer more than just inputs).  It's easier to copy data *from* a common place than to try to send it *to* many targeted places.  Does that thought help any?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SpriteBase.inputs
« Reply #4 on: 2012-02-13, 03:49:27 PM »
I was looking into the Display.cs file, and I seem to have found a function called DrawArrow (I believe it draws the arrows used for the plan editor, right?)
based on coordinates.

If you do remember back in the older Bone Animation project I asked you to look at, It used faux animation for the limbs.. It was just rotation of the Frameset.

I think I'll delete the sprites I use for the limbs: I'm not sure if this might make the game faster because the need to call rules on each will be gone, but I think I'll tinker with the DrawArrow function, so that it draws a specific graphic, and I can animate the Bone Animation by changing the Angle formed by the coordinates each frame, simulating limb movement.

This way I can control action directly from the TargetBox, I can easily make new Animation Sequences, and potentially save sequences (Walking, Running) as a set of sequences that can be interpreted by an Object on runtime by loading a textfile containing angular change each frame.

I can also make movement appear more natural! I'm going to look into this more. I was using a game engine which uses Lidgren.Network 2 years ago, (Where I came up with the idea to use that) and it uses a similar system for animating characters.