Official Community Forums
 
HomeHome  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  The Wiki  Website  github Project  

Share | 
 

 Manual Aim instead of Auto Aim

View previous topic View next topic Go down 
AuthorMessage
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Manual Aim instead of Auto Aim   Thu 27 Dec - 23:22

Hi,

I was wondering if it is possible or some sample code perhaps of implementing a manual aim system instead of point and click which MV currently uses.

Our goal is to build an FPS style game using MV, but we are planning to start first with melee weapons.

I know this is somehow related to Tristan's post here, any help would be much appreciated.
Back to top Go down
oldschool
Experienced Newbie
Experienced Newbie
avatar

Posts : 26
Join date : 2012-12-27
Location : Canada

PostSubject: Re: Manual Aim instead of Auto Aim   Sun 6 Jan - 13:25

Hello,

If holding right click which gives you 'mouse look' is what you want.
What I did was expose from the 'InputHandler' class the set and get method for the mouseLookLocked field.

then tied that up with some of the python and to an escape key press.
so now pressing escape gives the mouse look operation.
Back to top Go down
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Re: Manual Aim instead of Auto Aim   Mon 7 Jan - 9:58

Thanks for the reply oldschool.

Would you mind sharing or posting some working sample? Smile
Back to top Go down
oldschool
Experienced Newbie
Experienced Newbie
avatar

Posts : 26
Join date : 2012-12-27
Location : Canada

PostSubject: Re: Manual Aim instead of Auto Aim   Mon 7 Jan - 12:32


Sure,

In the Multiverse Client workspace for C# I will use the solution explorer tab to locate the Multiverse.Base project and open it and then into the 'input' section locate the file named:
InputHandler.cs

Open it, search for:
Code:

// Used by client API

note the method:

Code:

        // Used by client API
        bool CameraGrabbed { get; set; }
        bool MouseLookLocked { get; set; }

Note we have added access to the MouseLookLocked method for set and get, this will be exposed to the bindings file according to this comment:
Code:

// These are used by the bindings file

Also take mind that the output file that will contain this change is file:

MultiverseBase.dll

Next we move to the client side script file named :
ClientAPI.py

This is located in the Scripts folder on the client side.

Search the file for this code:
Code:

def GrabPlayerCamera():
    InputHandler.CameraGrabbed = True
   
def ReleasePlayerCamera():
    InputHandler.CameraGrabbed = False

We will add below it:

Code:

def GrabMouseLook():
    InputHandler.MouseLookLocked = True
       
def ReleaseMouseLook():
    InputHandler.MouseLookLocked = False

hah, python whitespace don't forget Razz

So now we want to bind escape to activate the method.

Starting in the AssetRepository for your world, here sampleworld is used, Locate the folder:
sampleworld/Interface/FrameXML/

Locate your binding.txt file, verify escape is bound to the command you want, currently it is bound to a name:
TOGGLEGAMEMENU

Relates to the bindings.xml file beside it which has the code:
Code:

        <Binding name="TOGGLEGAMEMENU" header="UIOPERATION">
                ToggleGameMenu()
        </Binding>

Here I have added the call to: ToggleGameMenu()

Here is the code:
Code:

def ToggleGameMenu():

   frame = getglobal("GameMenu_UI")

   if not frame.IsVisible():
      ClientAPI.Write("Open Game Menu")   
      frame.Show()
      ClientAPI.ReleaseMouseLook()
   else:
      ClientAPI.Write("Close Game Menu")
      frame.Hide()
      ClientAPI.GrabMouseLook()

I am certain we can leave you to handle the remaining portion which is to include this ToggleGameMenu in a python script that you load via an XML file decalared in a *.toc file.

Fairly certain I did not leave anything out, be sure to provide some feedback.
Hope it helps!

Back to top Go down
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Re: Manual Aim instead of Auto Aim   Tue 8 Jan - 8:07

Hey, thanks for this. I've been working on some other things now but will try as soon as I get a chance.

Thanks again.



Back to top Go down
Delurin
Head of Platform Development


Posts : 424
Join date : 2011-08-03

PostSubject: Re: Manual Aim instead of Auto Aim   Tue 8 Jan - 8:40

Just as warning you will probably need to modify Multiverse.Base.Client.CastRay by default if it doesnt hit a collision object it will return an object if it hits its bounding box (which would probably be a miss in a shooter)
Back to top Go down
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Re: Manual Aim instead of Auto Aim   Wed 9 Jan - 15:28

ok thanks for the heads up Delurin
Back to top Go down
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Re: Manual Aim instead of Auto Aim   Tue 5 Mar - 14:31

Works great oldschool! That did the job! cheers Thanks a lot

My next step now is the collision detection part that Delurin mentioned. I need to have the ray cast straight centered to the player's view if this is the default or something like that and attack on will, collision checking will now depend on weapon in use:

Melee = 1 - 2m equivalent
Projectile short range = 50m
Projectile long range = 50m up

Any ideas?
Back to top Go down
rotello
Super Contributor
Super Contributor
avatar

Posts : 215
Join date : 2012-12-06

PostSubject: Re: Manual Aim instead of Auto Aim   Wed 6 Mar - 19:16

Delurin wrote:
Just as warning you will probably need to modify Multiverse.Base.Client.CastRay by default if it doesnt hit a collision object it will return an object if it hits its bounding box (which would probably be a miss in a shooter)

Hi Delurin,

I'm still quite new on how the engine works, can you point me into the right direction on what files and lines should I modify to achieve this feature?

Thanks.
Back to top Go down
Sponsored content




PostSubject: Re: Manual Aim instead of Auto Aim   

Back to top Go down
 
Manual Aim instead of Auto Aim
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Manual Blipping on downshift
» The Magnificent Manual of Mastering Mysticism: A Guide to Magic
» User Manual's Online
» Auto Guard
» Clutch Assembly OEM

Permissions in this forum:You cannot reply to topics in this forum
 :: Development :: Client Scripting and Development-
Jump to: