Results 1 to 3 of 3

Thread: odd control scheme help

  1. #1
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default odd control scheme help

    Okay I don't know how many people know about my game, but my little brain dude Hypno-Joe will have sort of fps controls. Mouse aim his eyes to hypnotize his enemies, use w,a,s,d for movement (will have an option for left-handies later).

    Seth just told me a little of how the standard brain works. It will move the direction it's facing. However, it looks like it will be a problem with this control scheme, because he's only going to change which way he faces when you move the mouse to the opposite side of him. So that if you wish he can walk backwards (say if I decide a baddie is controllable, he'll need to face the enemy and still be able to move).

    anyone have suggestions on what's best to do. I could ForceVisual -- override the animation that's displayed, but then i'd need to track the way he's facing manually. Or do I do it all manual?

    Also how do I do it manual? I usually call SetDesiredSpeed to make him move, so would this be a simple case of setting a negative value to go backward, or is this function tied in with the standard brain?

    Any ideas guys?

  2. #2
    Squire
    Join Date
    Jan 2008
    Posts
    19

    Default

    You could track which side of the character the mouse is by doing something like:
    local vPlayerPos = this:GetPos()
    local vMousePos = GetInputManager:GetMousePos()
    local nXDiff = vPlayerPos.x - vMousePos.x

    I'm not entirely sure if you need to use ScreenToworld() or WorldToScreen on one of them, it depends on if they both give you screen or world coordinates.
    And then if nXDiff is negative that means the mouse is to the right of him because the mouse X coordinates will be bigger then the players X coordinates.
    And if it's positive then the mouse is to the left of him.
    Then you could probably force visual or use two different visual profiles for left and right depending on if it's negative of positive, to have him always face towards the mouse.

    Also you would probably disable the feature that inverts the sprites for the character depending on which direction key is pressed. I don't know how to do that though.

  3. #3
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    Thanks for the help with the mouse thing. I will probably do that, and will check on whether i have to convert the coordinates. After learning about this a little more, I'll probably detach the standard brain from my character and use SetAnimByName -- it will also start playing when I set it. Going to make a little maybe partial tutorial on doing animations manually. Since the profile has the ability to control how the animation goes, I will probably simply make a state that uses the same frames only backwards and name it something like Walk_right_backwards (or something to that effect). From what I understand SetVisualState will also play an anim, but it resets, and it can only do the 10 pre-defined animation states, and 8 directions for each of those. Not that this is exactly limiting but just my control scheme is so unusual a custom method is needed. SetVisualState, as I understand it, is mostly for the internal stuff. For instance if you're using the standard brain and you set it facing left, the engine will basically call SetVisualState -- Although Seth could be explain if that's right or wrong. In any case, i'll be writing a small-ish tutorial on "rolling your own" so-to-speak.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •