Jump to content

Spectator Cam?


MikeClarke
 Share

Recommended Posts

I'm starting to feel extremely thick now, i love the tools and love the engine but i must have broken the cam about 30times today lol. Is there a v.simple way I can add a camera, and just spectate through the map (fly through the air)

 

I dont need it to follow a player etc Just want it to fly around so i can view the map im working on without making it all accessible to a player just now (ie i can add ladders, without not being able to climb them stopping me from viewing the rest)

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

A bit of a hopeful request, is anyone able to whip me up a small lua script i can just attach to a camera that has mouse controls (ie free-look, left click to go forward) its just so i can actually move through the levels i am in the process of putting together. I know it's alot to ask it's more of a hopeful reaching.

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

Tested and approved : Have fun smile.png

(It's made by Chriss and is found on Asset scripts forum part)

 

----------------------------------------------------------------------
--This script will add mouse and keyboard controls to a camera
----------------------------------------------------------------------

function Script:Start()
self.camerarotation=Vec3(0)
self.mouseposition=Vec2(0,0)
self.movement=Vec3(0,0,0)
self.movespeed=20
self.lookspeed=0.1
self.movesmoothing=8
self.looksmoothing=5
self.entity:SetMass(0)
self.entity:SetCollisionType(0)

self.pivot = Pivot:Create()
local shape=Shape:Sphere(0,0,0, 0,0,0, 1,1,1)
self.pivot:SetShape(shape)
self.pivot:SetMass(1)
self.pivot:SetGravityMode(false)
self.pivot:SetPosition(self.entity:GetPosition(true),true)
self.moveforce=Vec3()
self.mouseposition=Vec2()
self.mousespeed=Vec2()

local window = Window:GetCurrent()
local cx=window:GetClientWidth()/2
local cy=window:GetClientHeight()/2
window:SetMousePosition(cx,cy)
end

function Script:UpdatePhysics()
local window = Window:GetCurrent()
local cx=window:GetClientWidth()/2
local cy=window:GetClientHeight()/2
local camerarotation = self.entity:GetRotation()
local mousepos=window:GetMousePosition()	
window:SetMousePosition(cx,cy)	
self.mousespeed.x = Math:Curve(mousepos.x-cx,self.mousespeed.x,self.looksmoothing)
self.mousespeed.y = Math:Curve(mousepos.y-cy,self.mousespeed.y,self.looksmoothing)
camerarotation.x = camerarotation.x+self.mousespeed.y*self.lookspeed
camerarotation.y = camerarotation.y+self.mousespeed.x*self.lookspeed
self.entity:SetRotation(camerarotation)

local desiredvelocity=Vec3()

if window:KeyDown(Key.D) then desiredvelocity.x = desiredvelocity.x+1 end
if window:KeyDown(Key.A) then desiredvelocity.x = desiredvelocity.x-1 end
if window:KeyDown(Key.W) then desiredvelocity.z = desiredvelocity.z+1 end
if window:KeyDown(Key.S) then desiredvelocity.z = desiredvelocity.z-1 end

desiredvelocity=desiredvelocity*self.movespeed
desiredvelocity = Transform:Vector(desiredvelocity,self.entity,nil)

local currentvelocity=self.pivot:GetVelocity()
desiredvelocity.x=Math:Curve(desiredvelocity.x,currentvelocity.x,self.movesmoothing)
desiredvelocity.y=Math:Curve(desiredvelocity.y,currentvelocity.y,self.movesmoothing)
desiredvelocity.z=Math:Curve(desiredvelocity.z,currentvelocity.z,self.movesmoothing)
self.moveforce=(desiredvelocity-currentvelocity)*60.0	
if self.moveforce:Length()>0 then
	self.pivot:AddForce(self.moveforce.x,self.moveforce.y,self.moveforce.z)
end
end

function Script:Render()
self.entity:SetPosition(self.pivot:GetPosition(true),true)
end

Stop toying and make games

Link to comment
Share on other sites

Almost but not quite, this basically has the player controls (with small left/right mouse look). I can't turn around or go high into the air etc which was my issue with using the character. The ability to go up down & turn around are the important aspect because i'll need to go through tunnels, up & down inside of buildings (which have ladders not ramps/steps etc)

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

@MikeClarke :

 

You don't have tested the script i gave to you angry.png

It's a free camera you can fly go anywhere, just press forward key and use mouse to choose direction.

You just need to attach it to a camera and run the game.

 

I think i will respond only to minimum serious people from now laugh.png

Stop toying and make games

Link to comment
Share on other sites

I did that :P (slow response as i took my daughter to scouts)

 

The mouse "look" was seamingly locked, it only had minor left/right. No up/down. So i couldn't turn around or fly about etc.

 

I'm using LE3 is this for LE2 perhaps?

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

Rick Response, ideally that style yes. At the moment its not a "major" issue, but I want to check the lighting with some transparent brushes and with doors opening/shutting etc Which i can't really see the "in motion" from the editor.

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

Feww... man you have problems to read and understand what is posted ...

Nope the script is LE3 : DID YOU READ ? I PUT TESTED AND APPROVED.

 

I repeat :

The camera uses mouse for free 3D space orientation, you just press "Z" key to run in the direction the mouse points.

This way you can navigate anywhere in your world.

 

I think you need strafe features ? it don't have that for now. Are ypu making a space ship game ?

 

Anyway good luck with your project ... i give up to try helping you laugh.png too hard laugh.png

Stop toying and make games

Link to comment
Share on other sites

Must admit despite the initial help you provided the attitude since is a little "off-putting". I have saved the script as Spectator.lua, I have added a camera, i right click "Add Script" select the Spectator.lua and Ok. I then run the game.

 

I Cant turn fully, or fly around pressing Z or wasd (Or mouse), I have "Limited" turning and zero adjusting height.

 

So you tested & it worked. I'm using it on nothing but the demo (replacing existing camera) and it didn't work.

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

ok i'll try (i made the effort to take on my free time , and made a post for him with the camera script, i also responded to it's questions, well it's more loosing patience i think, i could have just posted code and let him with it)

 

@MikeClarke:

Indeed the demo is already full of scripts running, and it has already a camera, perhaps it's the problem ?

having two cameras i don't think it will work.

I suggest you to forget the demo and make a new level :

Add a block BSP

Add directionnal light

Add camera

Attach this code to the camera

And it will work.

Forget that demo, and make your own test level or directly your own new game level.

 

I can't do more to help you, now it's up to you to learn.

Stop toying and make games

Link to comment
Share on other sites

I found out what was causing the error. It wasn't a camera as i had already removed them prior to the test. It was the player model. The attached script is conflicting due to the player controls.

 

I did thankyou for the help earlier & will repeat in doing so. Although i would offer a minor bit of advice. The first being from my post count you can see i'm new here and the bit where i'm using the demo means i haven't yet parted with my cash. So in the interest of getting a "growing community" it would probably be a good idea not to put people off. Granted it won't affect your bottom-line but it will to LE and the more money they get the better product you get. Secondly (and lastly), I'm obviously not the most well equipped to provide you with assistance when it comes to coding, but there are other skills myself & others have. So it's generally a good idea to be less hostile, as someday you may need these people to help and they would be disinterested given the way you made them feel.

 

Now i'm a big boy and can & will quite quickly move beyond this, now i will once again thankyou for the assistance provided it will be of great use to me over the coming weeks and has also saved me many hours of time since I'm not ready to get into the scripting side of LE.

  • Upvote 1

Operation Mosquito

Recruiting 3d Modeller/Animator. (pm if interested)

 

It is the greatest of all mistakes to do nothing because you can do only a little. Do what you can. - Sydney Smith
Link to comment
Share on other sites

So it's generally a good idea to be less hostile, as someday you may need these people to help and they would be disinterested given the way you made them feel.

 

I agree.

I had at same time that day some anomalies with LE3 , and code not going where i wanted with Leadwerks 3, i think it charged my mood in the bad way.

Sorry for looking so hostile, but even like that i kept trying to help you also, but perhaps it was better to let other people help you if they can. I responded to you to not let you down all the day, but well, not so good idea.

Next time in such mood i will just post code if i have or advice and let other people continue the help instead of me.

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