|
Posted By
|
Message
|
 jamesh
Registered 2/28/2012 3:24:25 PM
Points 380
|
5th July, 2012 at 7/5/2012 1:26:21 PM -
Hi
I want to have a really smooth scrolling camera - a bouncing ball with speed constantly set to the distance it is (in pixels) from the player object.
How can I find the distance between the camera and the player object?
n/a
|
 vetmora120
Registered 1/7/2010
Points 281
|
5th July, 2012 at 7/5/2012 1:59:18 PM -
With the advanced direction object. Alternatively, if you're not keen on using extensions for these sorts of equations, then use the following formula:
Sqr( ( X( "Object 1" ) - X( "Object 2" ) ) pow 2 + ( Y( "Object 1" ) - Y( "Object 2" ) ) pow 2 )
In which case Object 1 would be the camera, and Object 2 would be the player. Or vice versa. Shouldn't which is which in this situation.
The universe of Vetmora.
|
 Chris Burrows
Registered 9/14/2002
Points 2396
|
5th July, 2012 at 7/5/2012 2:12:22 PM -
Is the camera a separate object?
Distance = Abs(X("Player")-X("Camera"))
Or if you want X and Y scrolling...
Distance = Sqr((X("Player")-X("Camera"))pow 2+(Y("Player")-Y("Camera"))pow 2)
Or if you need the distance between the player and the edge of the window...
Distance from top = Y("Player") - Y Top Frame
Distance from bottom = Y Bottom Frame - Y("Player")
Distance from left = X("Player") - X Left Frame
Distance from right = X Right Frame - X("Player")
n/a
|
 Chris Burrows
Registered 9/14/2002
Points 2396
|
5th July, 2012 at 7/5/2012 2:31:57 PM -
Beat me to it.
n/a
|
 vetmora120
Registered 1/7/2010
Points 281
|
5th July, 2012 at 7/5/2012 2:56:24 PM -
Heh. Your response was slightly more elaborate.
The universe of Vetmora.
|
 nim
Registered 5/17/2002
Points 7046
|
5th July, 2012 at 7/5/2012 4:02:12 PM -
Download Snippet Manager 2 by Sketchy. It comes with a bunch of useful formulae like this.
http://create-games.com/download.asp?id=8227
//
|
 jamesh
Registered 2/28/2012 3:24:25 PM
Points 380
|
5th July, 2012 at 7/5/2012 5:39:30 PM -
Originally Posted by vetmora120 With the advanced direction object. Alternatively, if you're not keen on using extensions for these sorts of equations, then use the following formula:
Sqr( ( X( "Object 1" ) - X( "Object 2" ) ) pow 2 + ( Y( "Object 1" ) - Y( "Object 2" ) ) pow 2 )
In which case Object 1 would be the camera, and Object 2 would be the player. Or vice versa. Shouldn't which is which in this situation.
This is absolutely magic, it works perfectly! Thanks guys.
n/a
|
|
|
|