Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Game programming

Moving camera

All about the StoneScript

Moving camera

Postby Kaldrick » 20 Oct 2011, 14:13

Hello. I have one small question. I was using iPhoneJoypadEmulation2 code to make my own little camera and character movement. With few changes I managed to make it always face -z axis, and that character is automatically moving forward, and can't really move back. But he can slow down - and I'd wish to move camera back, when he does. This is a sample code I use:
Code: Select all
        object.matchTranslation ( hObject, hDynObj, object.kGlobalSpace )
        object.translate ( hObject, 0, 4.2, 3.5, object.kGlobalSpace )
        object.translate (hDynObj, 0, 0, -0.1, object.kGlobalSpace)
        local x,y,z = object.getTranslation ( hDynObj, object.kGlobalSpace )
        local w,b,d = object.getTranslation ( hObject, object.kGlobalSpace )
        object.resetRotation ( hObject, object.kGlobalSpace )
        object.setRotation ( hObject, -30, this.nAngleY ( ), 0, object.kGlobalSpace )
        object.rotate ( hObject, this.nAngleX ( ), 0, 0, object.kLocalSpace )

Any help?
Kaldrick
Fresh Boarder
Fresh Boarder
 
Posts: 6

Re: Moving camera

Postby RedQueen » 20 Oct 2011, 22:49

You can just parent the camera to the character. That is the simplest way. That way it will move where ever the character does.
RedQueen
Platinum Boarder
Platinum Boarder
 
Posts: 328

Re: Moving camera

Postby Kaldrick » 21 Oct 2011, 12:51

And how to do so? ;P
Kaldrick
Fresh Boarder
Fresh Boarder
 
Posts: 6

Re: Moving camera

Postby RedQueen » 21 Oct 2011, 13:39

Documentation is here as to how to setup parent->
http://www.stonetrip.com/developer/doc/api/object-setParent
RedQueen
Platinum Boarder
Platinum Boarder
 
Posts: 328


Return to Game programming

cron