MrKsoft Posted August 17, 2007 Report Share Posted August 17, 2007 I am adding a boss area into the second act of my game but I am coming across difficulty in making the camera move into it properly. How would you recommend making the camera smoothly lock into the center of the 320x240 boss section of the level? All the ways I have tried made it move to the center of the boss area immediately, which is slightly disorienting and very unprofessional/ugly. Link to comment Share on other sites More sharing options...
DimensionWarped Posted August 17, 2007 Report Share Posted August 17, 2007 I'd just do it the cheap way and disable the camera group before I reset the x limits. Link to comment Share on other sites More sharing options...
Damizean Posted August 17, 2007 Report Share Posted August 17, 2007 That would make Sonic be able to get outside the limits. I suggest you use LERP (linear interpolation) for smoothly changing the limits. 1 Link to comment Share on other sites More sharing options...
DimensionWarped Posted August 17, 2007 Report Share Posted August 17, 2007 Actually as long as you change the limits of the camera object, you can't go outside of them even when the camera group is disabled. Thats how I did it with the various level ending things anyway. Worked fine. Link to comment Share on other sites More sharing options...
MrKsoft Posted August 18, 2007 Author Report Share Posted August 18, 2007 I tried doing this in an event, which disabled the camera group, set the new limits, and reactivated the camera group (I checked, and they ARE happening in that order) but it merely does the sloppy jumping and doesn't move into it as it does in the old classic games. Also, I realized that I had an implementation of linear interpolation in an unfinished game of mine, but efforts to try to adapt it for SW seem unsuccessful (I end up battling against the already-established camera events) Link to comment Share on other sites More sharing options...
Zenor Posted August 18, 2007 Report Share Posted August 18, 2007 The cheap way: set an value. make an other value add/subtract 1/2/3 every time to be equal to the 1° value. Link to comment Share on other sites More sharing options...
MrKsoft Posted August 18, 2007 Author Report Share Posted August 18, 2007 Actually, Dami solved it for me on AIM. Super thanks and rep for him! Link to comment Share on other sites More sharing options...
Streak Thunderstorm Posted August 22, 2007 Report Share Posted August 22, 2007 Yeah but this should be shared with the community because I too am having the same problemo. Link to comment Share on other sites More sharing options...
Asuma Posted August 22, 2007 Report Share Posted August 22, 2007 Same here. Link to comment Share on other sites More sharing options...
Sir Euan Posted August 22, 2007 Report Share Posted August 22, 2007 No cos you don't deserve it! Link to comment Share on other sites More sharing options...
Kain Posted August 22, 2007 Report Share Posted August 22, 2007 "Linear Interpolation" sounds like a complicated term, but it's really quite simple: it's taking two points and forming a smooth line between them. The formula per-dimension is as simple as you're going to find, namely: point = starting_point + (ending_point - starting_point) * percent_done/100; You can replace "percent_done/100" with "current_step/max_step" or any such thing. There are a number of different ways you can do it in the Sonic Worlds engine. Since I can't find the Sonic Worlds engine on my computer, I'll just say the most general way: and that'd be to start the boundry as the boundry you want it to be + the width/height of the screen at all points. Namely, you'd have camera_maxX + screen_width (or w/e the variables are called) as the maxX starting point, camera_minX - screen_width as the minX starting point and the same with Ys. You would have 4 starting_points and 4 ending_points (one for the minx, maxx, miny, and maxy) and 1 current_step and max_step. Using those, you would apply the above formula with current_step starting at 1 and adding 1 to it every frame to find the max/min x/y to put into the engine. Link to comment Share on other sites More sharing options...
Asuma Posted August 22, 2007 Report Share Posted August 22, 2007 Would you mind um, explaining a bit more. I have no idea what Linear Interpolation is. Link to comment Share on other sites More sharing options...
Kain Posted August 23, 2007 Report Share Posted August 23, 2007 Er... that's all there is to it. current_point = starting_point + (ending_point - starting_point) * factor_done; Where factor_done is between 0 and 1. For example, if you want to create a smoothly transition an object's position from it's current position to a new position (say 0,0) over the course of 30 frames: First you would define the starting_points and ending points for both the x axis and y axis. You'd also initialize a variable to keep track of what frame you're on, and you'd also say how many frames you want this to be over. I guess you'd also turn a flag or something to signify that you're interpolating on: starting_x = X("object") starting_y = Y("object") ending_x = 0 ending_y = 0 current_frame = 0 max_frames = 30 interpolating = 1 Then, every step, if interpolation is on, you'd add 1 to the current_frame and determine the object's X and Y position from the above formula: current_frame = current_frame + 1 X("Object") = starting_x + (ending_x - starting_x) * current_frame / max_frames Y("Object") = starting_y + (ending_y - starting_y) * current_frame / max_frames Then, if interpolation is on and current_frame is bigger or equal to max_frames, you'd set the X and Y to the ending point and turn interpolation off: X("Object") = ending_x Y("Object") = ending_y interpolation = 0 Link to comment Share on other sites More sharing options...
DimensionWarped Posted August 23, 2007 Report Share Posted August 23, 2007 Issue resolved then. *lock'd* Link to comment Share on other sites More sharing options...
Recommended Posts