About Store Forum Documentation Contact



Post Reply 
Mouse Character Control
Author Message
Viruzzz Offline
Member

Post: #1
Mouse Character Control
Hi,
I need a sample code for Mouse Character control and in sample have it work in both keyboard + mouse.

Thank You.

PS. I-am beginner in C++.
01-24-2012 01:19 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Psylixiri Offline
Member

Post: #2
RE: Mouse Character Control
actually there's some sample of code used for player in the tutorial of the sdk
for example
Code:
Players[0].angle.x-=Ms.d().x;
that code wich actually use your mouse device to translate the world around you according to your current player angle
[/code]
01-24-2012 04:08 PM
Find all posts by this user Quote this message in a reply
Viruzzz Offline
Member

Post: #3
RE: Mouse Character Control
don't work, any suggestion for this
01-25-2012 07:47 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #4
RE: Mouse Character Control
Why don't you use the examples? You have to update the input each frame.

PHP Code:
if(action)
    {
        if(
Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
    }

    if(!
action)
    {
        
// turn & move
        
input.turn.x=Kb.b(KB_Q)-Kb.b(KB_E);
        
input.turn.y=Kb.b(KB_T)-Kb.b(KB_G);
        
input.move.x=Kb.b(KB_D)-Kb.b(KB_A);
        
input.move.z=Kb.b(KB_W)-Kb.b(KB_S);
        
input.move.y=Kb.b(KB_SPACE)-Kb.b(KB_LSHIFT);

        
// dodge, crouch, walk, jump
        
input.dodge Kb.bd(KB_D)-Kb.bd(KB_A);
        
input.crouchKb.(KB_LSHIFT);
        
input.walk  Kb.(KB_LCTRL );
        
input.jump  =(Kb.bp(KB_SPACE ) ? 3.5f 0);

        
Flt max=DegToRad(900)*Time.d();
        
angle.x-=Mid(Ms.d().x*1.7f, -maxmax);
        
angle.y+=Mid(Ms.d().y*1.7f, -maxmax);
        
    } 

There is always evil somewhere, you just have to look for it properly.
01-25-2012 09:45 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Viruzzz Offline
Member

Post: #5
RE: Mouse Character Control
hmm, sry if dont understand me, i want to control character with mouse with button (1 2) aka keyboard (WSDA), i try this:

input.turn.x = Ms.b(0);

and dont work..
:|

PS. moving no camera control!
(This post was last modified: 01-26-2012 10:48 PM by Viruzzz.)
01-26-2012 10:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: Mouse Character Control
both of these has to be done in update()

input.turn.x = Ms.b(0)-Ms.b(1);
or
angle.x += Ms.b(0)*Time.d()-Ms.b(1)*Time.d()
01-26-2012 10:57 PM
Find all posts by this user Quote this message in a reply
Viruzzz Offline
Member

Post: #7
RE: Mouse Character Control
(01-26-2012 10:57 PM)Zervox Wrote:  both of these has to be done in update()

input.turn.x = Ms.b(0)-Ms.b(1);
or
angle.x += Ms.b(0)*Time.d()-Ms.b(1)*Time.d()

with this character doesn't move... is rotates. :|

and i try this and not works:
Code:
input.move.z = (Kb.b(KB_W) != Ms.b(0)) - (Kb.b(KB_S) != Ms.b(0));
input.turn.x = (Kb.b(KB_A) != Ms.b(0)) - (Kb.b(KB_D) != Ms.b(0));
(This post was last modified: 01-27-2012 08:11 AM by Viruzzz.)
01-27-2012 08:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #8
RE: Mouse Character Control
input.move.z = (Kb.b(KB_W) || Ms.b(0))-(Kb.b(KB_S) || Ms.b(1));
(This post was last modified: 01-27-2012 11:55 AM by Zervox.)
01-27-2012 11:53 AM
Find all posts by this user Quote this message in a reply
Post Reply