Jump to content

LE3 programming templates needs


YouGroove
 Share

Recommended Posts

Yes some non programmers like me we would like to see some good templates of code fo standard gameplay stuff, coded in the simpliest way possible, easy to learn.

It's just a whish Lits and reminder about we would want to see as gameplay and code.

 

So anyone can add what he would need in terms of code template.

 

- Real 3rd camera script

- Character player motion non FPS view : direction controlled by mouse , forward and backward by keys.

- gun and bullet code : shoot, and raycast collision

- rocket launcher code : shoot, movement or rocket , collision on entities or obstacles

- FPS camera driven by mouse and keys for (wlak forward , backward and strafe.

- Physic monkey ball game style control driven by mouse or keys

Stop toying and make games

Link to comment
Share on other sites

I created a slimmed down version of a camera script, it doesn't do any fancy raycasting but I feel is fairly readable.

 

Script.target = nil--Entity "Target"
Script.distance = 10--float
Script.debugphysics = false--bool
Script.debugnavigation = false--bool
Script.pitch = 20--float
Script.height = 10--float
function Script:Start()
if self.target==nil then return end

--debug functions for viewing physics or navigation in game
self.entity:SetDebugPhysicsMode(self.debugphysics)
self.entity:SetDebugNavigationMode(self.debugnavigation)

--Set the cameras rotation
self.entity:SetRotation(self.pitch,0,0)
end
function Script:UpdatePhysics()

--Exit the function if the target entity does not exist
if self.target==nil then return end

--Get the target entitys position, in global coordinates
local p0 = self.target:GetPosition(true)
--Calculate the new camera offset
local offset = Vec3(p0.x,p0.y+self.height,p0.z-self.distance)

--Add our original offset vector to the target entity position
p0 = offset
self.entity:SetPosition(p0,true)

end

Link to comment
Share on other sites

Thanks a lot Chris smile.png

 

I'm not good at maths vectors so i didn't how to manage the camera when it's not a simple travelling one.

 

I tested the code on a character that goes to a point with navmesh.

I put the character on target slot fo camera, the camera follow it, but never turns ?

It's another travelling camera :(

Stop toying and make games

Link to comment
Share on other sites

Other stuff needed :

The game demo is full of code , state machines, animations, all that in ONE file : not clear , confusing.

 

Why not having : All animation in one Lua file called by messages on GoblinAI ?

processAnimation("WALK");

one line to call another LUA Class

 

Same for states AI, they make things confusing.

 

****************

 

In fact it would be great to find a simple script to just move a cube in all directions.

- by keys use as actual game

- by using mouse direction and keys.

 

The SHORTEST simple code possible (no animations, no camera)

Stop toying and make games

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...