Jump to content

player.controller code


cassius
 Share

Recommended Posts

I have been trying to update the character controller code on the wiki for use with le 2.3 but had no success.

I need some code that will put a player inside a level with look around and mocement capability.

If anyone would share such code it would be much apreciated.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Thanks macklebee.

I got rid of the code last nijht after a couple of frustrating hours. The program ran with no errors. The lighting was on and you could lookaround with mouse but movement was frozen.

 

The problem was I did'nt know which commands were obsolete or no longer needed.

Is it true that LoadScene takes care of lighting now?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

The controller needs a mass now... I think the tut doesn't have that and if i remember correctly that was a bug from an older SDK version that Josh fixed... also, you need to set the acceleration value which I don't believe was in the old tut... but then again Josh redesigned the character controller completely since that tut was made... good rule of thumb is to look at the wiki for all of your commands and see if there has been any changes to what the parameters are now... try changing it and see what each one does for you...

 

and as far as I can tell the lua scripted lights when loaded from LoadScene just automatically work now... the position/rotation/color etc all seem to be set... at least for bmax users, I can't speak for c++

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

 

and as far as I can tell the lua scripted lights when loaded from LoadScene just automatically work now... the position/rotation/color etc all seem to be set... at least for bmax users, I can't speak for c++

 

 

Using C++ I have not found any problems with LoadScene automatically parsing the lights and setting them up in a scene.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Guest Red Ocktober

Mack... i ran your code... it worked perfectly...

 

you're making quick progress getting a grasp on this thing... thx for sharing... your collision code snippets helped me get my player guy reacting properly inside my sub...

 

 

--Mike

Link to comment
Share on other sites

Using C++ I have not found any problems with LoadScene automatically parsing the lights and setting them up in a scene.

 

now if we can only get emitters to work automatically in c++! :lol:

 

Mack... i ran your code... it worked perfectly...

 

you're making quick progress getting a grasp on this thing... thx for sharing... your collision code snippets helped me get my player guy reacting properly inside my sub...

 

thanks Mike, just trying to repay the community that helped me when I first started... now maybe one of these days I will actually produce something! :D

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

now if we can only get emitters to work automatically in c++! :lol:

 

 

:D

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

I too would like to repay the community for fantastic help over a long period but mostly my lack of expertise prevents it. I do however recommend le and the community at every oportunity.

It might be nice to have a "How to" section on the forum like:

How to open and close doors in a game

How to make an elevator go up and down

How to pick up objects....etc

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

I too would like to repay the community for fantastic help over a long period but mostly my lack of expertise prevents it. I do however recommend le and the community at every oportunity.

It might be nice to have a "How to" section on the forum like:

How to open and close doors in a game

How to make an elevator go up and down

How to pick up objects....etc

 

I was in the same boat cassius when I first started... heck, I am actually still in that boat!

 

and thats the whole purpose of this new forum/social development that Josh has envisioned... the goal being to be able to easily share assets whether it be code/models/scripts/whatnot... give it time to build up and I think you will get a form of that How to section you are looking for... At least I know I plan on exposing all I can figure out (and all I don't know) and sharing whenever I can...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Mack,

Your code with collisions is working for me too, thanks for that. :unsure:

 

glad i could help ;)

 

i am trying to finish setting up my bmax framewerk testing code that will set the water, distance fog, skybox, what have you... i will post that in my blog for anyone to use for testing if they wish...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

yeah, good point josk...

 

to get the oildrum lua script sound to work in your bmax framewerk program, you need this in your bmax code:

SetGlobalObject("listener", CreateListener(fw.Main.camera))

 

and this is the modified oildrum.lua code for the collision function:

--Add collision noise
function Collision(model,entity,position,normal,force,speed)
       local entity=entitytable[model]
       local time,i
       if fw~=nil then
               listener = fw.listener
       else
               listener=GetGlobalObject("listener")
       end
       if EntityDistance(listener,model)<30 then
               if speed>hitthreshhold then
                       time=AppTime()
                       if time-lasthitnoisetime>hitnoisedelay then

                               --Check how many impact noises are already active
                               local countsources=0
                               for i=0,2 do
                                       if hitnoise[i]~=nil then
                                               countsources=countsources+hitnoise[i]:ActiveSources()
                                       end
                               end

                               --Only emit a sound if there are fewer than the allowed max sources
                               if countsources<maxhitsources then
                                       i=math.random(0,2)
                                       if hitnoise[i]~=nil then
                                               entity.model:EmitSound(hitnoise[i],30,1.0,0)
                                       end
                               end

                               lasthitnoisetime=time+math.random(0,hitnoisetimevariation)
                       end
               end
       end
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

That works too, you're on a roll. :blink:

 

thanks gordonramp.

 

If any bmx users are interested, you can get an updated controller program from my blog that sets your skybox, water properties, and distance fog based on your Editor map, as well as give the option to set aa, bloom, godray, hdr, ssao, and wireframe during runtime... basically just what I am using to test the new editor and lua scripted objects...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...