cam movement

Blitz3D Forums/Blitz3D Beginners Area/cam movement

patisawesome(Posted 2003) [#1]
I'm trying to make my cam move up and down while I walk, I can't get it to! I've even tried AddAnimSeq. Can anybody help?
-me


jfk EO-11110(Posted 2003) [#2]
if the camera is parented to a player pivot:

if walking then a=a+1 mod 360
positionentity camera, entityx(camera,0), entityy(player,0)+.5*sin(a), entityz(camera,0),0


patisawesome(Posted 2003) [#3]
It doesn't work the way I want it to.
-me


WolRon(Posted 2003) [#4]
If you expect someone to offer help then you need to *EXPLAIN* HOW IT DOESN'T WORK, OR WHAT EXACTLY IS NOT WORKING CORRECTLY. Simply saying it doesn't work doesn't tell us anything. (We cannot read your mind...)


patisawesome(Posted 2003) [#5]
I mean that it's acting the way it was before!(In other words, it woundn't move up and down)
-me


jfk EO-11110(Posted 2003) [#6]
Well, "If walking" is pseudocode, of course. You must think with the code, not only copy and paste. so when your player is walking because of some keypresses or whatever, then set a variable named "walking" to 1, else to 0. To simplyfy this, just omit the IF statement. Also enlarge the Y-multiplyer to 2.0.

a=a+1 mod 360
positionentity camera, entityx(camera,0), entityy(player,0)+2.0*sin(a), entityz(camera,0),0

Also - you need a pivot named player that is parent of the camera to work with this
( player=createpivot(): camera=createcamera(player) )

Walking around will then no longer mean you have to move the camera, instead move the player-pivot, which will carry the camera automaticly. To turn around the player you will have to turn the player-pivot, while to look up or down you'll have to turn the camera.


patisawesome(Posted 2003) [#7]
It still doesn't work.
-me


Shambler(Posted 2003) [#8]
Post your code otherwise we'll be here until eternity ^^


patisawesome(Posted 2003) [#9]
Here is some of it:

If KeyDown(200)
MoveEntity cam,0,0,0.1
EndIf

If KeyDown(203)
TurnEntity cam,0,3,0
EndIf

If KeyDown(205)
TurnEntity cam,0,-3,0
EndIf

If KeyDown(208)
MoveEntity cam,0,0,-0.2
EndIf


puki(Posted 2003) [#10]
"patisawesome" This all seems to be for your "StormDimension" FPS project (Realistic Lighting/Acid/First Person Cam/Collision Detection/Gravity/FullScreen/Greate Models!). Your code suggests you are not using "mouse-look" (you are turning the camera with the keys) - refer to your "Firing" post.


patisawesome(Posted 2003) [#11]
I am turning with the keys. The reason why is that it won't turn when I move the mouse.
-me


patisawesome(Posted 2003) [#12]
I changed my code so that the cam swivels around when the mouse moves.
-me


GameCoder(Posted 2003) [#13]
you could also try using the less powerfull makequake2() function. That again works perfactly for me :D


patisawesome(Posted 2003) [#14]
Whats MakeQuake2?
-me


Doggie(Posted 2003) [#15]
It's not documented.

Try my world creator or else!
(It's the link below. It writes Blitz code for you!)

Doggie

This reply is an advertisement for HomeSpun GOLD(A)


patisawesome(Posted 2003) [#16]
It doesn't tell how much it costs.(Or is it free?)
-me


Doggie(Posted 2003) [#17]
Just click on the picture of it and find out!

Doggie


Ross C(Posted 2003) [#18]
Mmmm, it seems that you have really read much about the blitz commands or looked through any of the samples. There are many ways you could make the camera bob up and down.

1. Try the MakeQuake2 Function, as mentioned above (although i think it's over-rated ;) )

2. Use the moveentity command to move the camera up until it reaches a certain height, then move it down till it reaches a certain height, then repeat.

3. You could make use of the sin command, to make the camera move in a wave like fashion.


patisawesome(Posted 2003) [#19]
None of it will work.
-me


DarkEagle(Posted 2003) [#20]
yes it will:
positionentity cam,0,sin(millisecs())*5,0


the camera moves up and down


GameCoder(Posted 2003) [#21]
It doesnt work. None of it. Any of it. Why doesnt it work?


patisawesome(Posted 2003) [#22]
It works, but it's too jerky.
-me


WolRon(Posted 2003) [#23]
Then modify it so that it does work.

patisawesome, you really need to try harder. Trial and Error, it's called.

You have to do it yourself, because with what little information you provide the rest of us here on the forum, we just can't help you.

Don't you see that they are mocking you?
Try the MakeQuake2 Function, as mentioned above (although i think it's over-rated ;) )

It's not documented.

It doesnt work. None of it. Any of it. Why doesnt it work?


Either you have to be MUCH more descriptive on what your problem is or you will just have to do it yourself. That's reality. If you want help, then take the time to write here the problem IN DETAIL.


Ross C(Posted 2003) [#24]
Hey Pat. How old are you anyways? Serious question. I'd like to help you, but as WolRon says, you aren't giving good descriptions of your problems you have in many posts i've seen. I'm not getting on at you man, but you should try a little hardre. You'll learn alot more too :)

Can you show us any code you have so far for making the camera move up and down?


patisawesome(Posted 2003) [#25]
Here is the code I have so far for walking up and down:
If KeyDown(200)
MoveEntity cam,0,0,0.1
PositionEntity cam,EntityX(cam),Sin(MilliSecs()*100/time,EntityZ(cam)
EndIf

-me


Ross C(Posted 2003) [#26]
Hey, it's uncommented and done quickly and works. Change the variables bob_speed and bob_height to adjust the bobbing :)

Graphics3D 800,600
SetBuffer BackBuffer()


camera=CreateCamera()
PositionEntity camera,0,1,0

light=CreateLight()

tex=CreateTexture(64,64,1+8)
SetBuffer TextureBuffer(tex)
For loop=0 To 1000
	Color Int(Rnd(20,255)),Int(Rnd(20,255)),Int(Rnd(20,255))
	Rect Int(Rnd(0,62)),Int(Rnd(0,62)),2,2
Next

SetBuffer BackBuffer()

Dim cube(100)
For loop=0 To 100
	cube(loop)=CreateCube()
	PositionEntity cube(loop),Rnd(-11,11),-0.5,Rnd(-100,200)
Next

plane=CreatePlane()
EntityTexture plane,tex

bob_angle=0
bob_height=100
bob_speed=8
y_pos=1

While Not KeyHit(1)


	If KeyDown(200) Then
		bob_angle=bob_angle+bob_speed:If bob_angle>359 Then bob_angle=0
		MoveEntity camera,0,Sin(bob_angle)/bob_height,0.1
	End If

	UpdateWorld
	RenderWorld
	Flip
Wend
End



eBusiness(Posted 2003) [#27]
Ain't you supposed to be able to rotate, and move into another direction? Cause that's the hard part of it, especially if you don't know sinus and cosinus. (You doknow about then, right patisawesome? Please say you do.)


Ross C(Posted 2003) [#28]
Wouldn't say that it was particulary hard. Pat hasn't exactly been 100% clear about what he's after :)


patisawesome(Posted 2003) [#29]
I don't know about them eBusiness.
-me

edit
I also still cannot get it to bob up and down. I even modified around with my code!


Ross C(Posted 2003) [#30]
Well, Sin and Cos are basically mathimatically waves. If you input an angle into sin, it will return a ratio between the x and y. You can use this waves to create smooth motions, like the bobbing one.


patisawesome(Posted 2003) [#31]
I'm getting better results...
-me


Ross C(Posted 2003) [#32]
Keep at it :) Good way to learn :D


Tom(Posted 2004) [#33]
One of Filaxs' demos had some good camera-bob code! :)

Ask him if he'd share it? Although you may want to tone it down a bit, when I tried his demo it made me dizzy :)