Standard is X,Y 0 the centre of the scene image (Red dot).
I would like to set it to where I have drawn the green dot.
So Y 0 should be at the “feet” of the image or at least the destination.Y.
Because I want the character to walk to a destination object (with mouse click) and stop as he reaches the object. Not walk over it, which is the case when Y is in the middle of the scene.
How can I set this?
And for instance with walking to the right the X destination should be bottom right so the character stops when his feet touches the object right of him.
The whole ‘World’ coördinate system is confusing.
I want my graphics coordinates to be the same as the screen resolution dimensions, so in my case correspond with a resolution of 2560 x 1440 pixels.
I cannot get the Transform dimensions.
My character sprites are 360 pixels width and 630 pixels heigth. So the scene scales itself to this.
When i want bottom-middle of the sprite-scene to be the destination, X destination has to be 360/2 and Y 0.
When I move mouse scene to bottom left of the screen it should be 0,0.
Now it’s as you can see in the picture (mouse eye icon).
Ok, but then maybe, because I use scenes as children of the PlayerTransform I can use this just on the direction scenes I already have. Because the Destination ‘point’ has to differ for all directions.
So in my example above: Vector3(0, 315, 0) for just the WalkFrontScene
And Vector3(-180, 315, 0) for WalkRight.
Still I would prefer resolution pixel coördinates as with Windowbase.
if Player.WalkBack then
Player.Y := Player.Y + 1;
PlayerTransform.Translation := Vector3(Player.X, Player.Y, -Player.Y);
Player.S := 1 - 0.0015 * (Player.Y + 420);
PlayerTransform.Scale := Vector3(Player.S, Player.S, Player.S);
Y has a ‘maximum negative value’ of -419 to have the character bottom down on screen.
With Y 419, Scaling has to be 1, so I add 420.
Walking back will add to Y, but scaling down has to be just 0.001 with every Y.
I would suspect that things would go wrong when Y becomes a positive value (as Y= 0 is in the centre of the background scene) but the scaling is fine.
I will put a picture here when I have succeeded the same with all character scenes.
About this sentence: To be clear, you can do this easily, but it’s bad idea.
You can just not use UI scaling (put <ui_scaling mode="None" /> in CastleSettings.xml, see Customize look by CastleSettings.xml | Manual | Castle Game Engine , or even just remove <ui_scaling... element – it is default). Then you just set and see the UI control sizes in actual pixels (MyViewport.Width, MyViewport.EffectiveWidth etc. just reflect actual pixels).
Moreover if you don’t set any projection size, by leaving default MyViewport.Camera.Orthographic.Width and MyViewport.Camera.Orthographic.Height equal to zero, then the distances you see are just the same as UI sizes. So they will reflect actual pixels, if you turned off UI scaling. And you can leave `MyViewport.Camera.Orthographic.Origin at (default) zero to have origin in left-bottom corner.
So you can easily have the case “I just want to operate in device pixels”. That said, it is a bad idea. Other people don’t have 2560 x 1440 screen, they may also want to run game in window mode. Whatever you design will look bad on their systems, as they have smaller or larger screen. That is why we advise UI scaling, and Customize look by CastleSettings.xml | Manual | Castle Game Engine by default sets it up.
Ok, so it’s not a good idea. The problem I am struggling with is that 0,0 is in the middle / centre of the viewport, so with scene moving left x has negative value and moving down y has negative value. This makes it hard to control scenes as I have to reverse formulas etc.
So when 0,0 is bottom left as in window it would help.
This perhaps is also the problem I have with the moving in 8 directions with tan2 because of the negative values calculated. (see topic).
Could you please also look at the boolean problem when changing scenes that causes hickup (but with string it works okay). See links to the small videos I uploaded. Thanks!
I think you set it yourself to be in the center of the viewport, by setting Camera.Orthograhic.Origin to (0.5, 0.5), during one of the earlier threads on this forum. By default Camera.Orthograhic.Origin is (0, 0) and it means that position (0, 0) results in the left-bottom corner of the viewport.
You can set Camera.Orthograhic.Origin to whatever is comfortable for you, though also make sure it makes sense for different aspect ratios (what happens when user doesn’t have 16 : 9 but e.g. 16 : 10 screen size). Whether positioning vs center or vs left-bottom corner is better in this viewport – up to a particular game.
I tried changing Translation of Location(TCastleTransformDesign) but it has no effect on the size and placement.
Location.Transform := TransformLoad('castle-data:/'+ Location.Name + '.castle-transform', LocationOwner);
Location.BackgroundScene.Translation := Vector3(1200,700, 1); // does not do anything?
Location.Transform.Translation := Vector3(50, 50, 1); // shows just part of the background scene and it is scaled too high
(This Transformdesign point to designs that has scenes with background picture URL.
This is too much confusing notes, and things that we cannot help with without knowing the details.
Please, create a small (as small as possible) project to reproduce each problem you have. Then we can resolve them, one by one.
The TCastleTransformDesign translation should work, the labels should be visible on top of your viewport. But is not possible to debug what is wrong in your case just from looking at the screenshots, I’m afraid.
I just found out that the Label texts are not showing up because of their placement.
It appears that the size of the background is the size of the Viewport.Items Root Transform.
and so the background picture showing part is limited to its size?
Now the scaling is allright and the only old problem is again: placing it fully on screen with Orthographic origin still at 0,0.
Hm, by setting the Translation of the RootTransform I got the full background picture again.
So this maybe good; however now there is a distance between the system mouse coordinates and playerscene mouse.
That’s because I have in code:
PlayerMouse.Scene.Translation := Vector3(Mainviewport.PositionTo2DWorld(Container.MousePosition, true), 10);
But also the PlayerTransform 0,0 is now in the centre of the screen, so this is not good.