Problem working out the ball controller using CodeMonkeys Pool Table template
Chunkypixels
Member Posts: 1,114
hi...
Im working on building a minigolf game based off CodeMonkeys Pool Table Template and have run into a problem with the ball direction/power meter not working properly.
I want to make my play area larger than just one screen size, so have extended the level size to 1200x1200 to give me space to build larger courses, and Ive set the camera to be linked to the ball to help avoid getting the ball tight up to the side of the screen so it makes it easier to select and control.
As part of this, Ive moved everything into the middle of my level to give space around the immediate play area.
My problem is that once i moved everything, the ball pullback/direction controller now doesnt work properly... almost as if its still anchored somewhere below my current play area... and only wants to rotate around the bottom edge of my ball.
Im assuming its something in the constraints of the ball,the crosshair or connector, but cant figure out which, as Im still pretty new to GameSalad and haphazardly stumbling my way through learning how everything works.
Is anyone able to point me in the direction of what i need to be looking at changing.
thanks....
Im working on building a minigolf game based off CodeMonkeys Pool Table Template and have run into a problem with the ball direction/power meter not working properly.
I want to make my play area larger than just one screen size, so have extended the level size to 1200x1200 to give me space to build larger courses, and Ive set the camera to be linked to the ball to help avoid getting the ball tight up to the side of the screen so it makes it easier to select and control.
As part of this, Ive moved everything into the middle of my level to give space around the immediate play area.
My problem is that once i moved everything, the ball pullback/direction controller now doesnt work properly... almost as if its still anchored somewhere below my current play area... and only wants to rotate around the bottom edge of my ball.
Im assuming its something in the constraints of the ball,the crosshair or connector, but cant figure out which, as Im still pretty new to GameSalad and haphazardly stumbling my way through learning how everything works.
Is anyone able to point me in the direction of what i need to be looking at changing.
thanks....
Comments
The only thing i can think of is to open up the scene layer tab and make sure there is only one actor of the cue ball. If there is two it will wig out
There are also a few various actors around that are teh cross hairs and the aiming bar etc that are invisbale until you fire it off make sure those are still there. They should be able to be laying anywhere and be fine
Its probably easier to see the problem, rather than me try and describe it.
Ive uploaded a template called MiniGolf_test_broken
...thanks
If someone would be willing to have a look at my controller issue as described above, and give me some guidance on what is going wrong, and how to fix it... ideally with an explanation on the workings and processes involved, so that I can learn something from it I'd be extremely grateful.
Im a professional artist and can offer to do a set of the 512x512 and 57x57 (or iPad size) app icons in return for first person that can provide me with a fix to my problem.
thanks....
thanks
Would that be an offset to the ball, or the attached crosshair/powerbar actors? Im assuming its the crosshair actor, as thats the one with the long constraint rules that Im having difficulty understanding.
I have absolutely no previous coding experience, so basically Im who GameSalad is meant to be aimed at, but some of the longer rules still look like some sort of scripting/code to me, which is why I could really do with some sort of breakdown and description of what all the attributes and rules actually mean.
The GameSalad documentation is missing a lot of details, and doesnt explain how everything should be used together, so Im finding a lot of things are trial and error, and working from other peoples templates in order to try and learn.
Create an actor that Constrains those attributes to some values. (Using a Constrain Attribute behavior for each of the created attributes, but the target value doesn't matter in the prototype.)
Add the actor to the scene and edit it. (Unlock the instance)
Change the Constrain Attribute target values(right hand side) to the corresponding scene attributes for the camera origin. (i.e. scene.Camera.Origin.X or scene.Camera.Origin.Y)
Now in any other actor that uses game.mouse.Position.X/Y or game.Touches.Touch *.X/Y add the attributes created above. So if you have an expression:
120-game.Mouse.Position.X
you would change it to be
120- (game.Mouse.Position.X + game.CameraOriginX)
In the pool table project you would just do the steps above and edit the Reticule actor which has the behaviors using the mouse position.
game.CueY +min(100, magnitude( game.CueX -( game.Mouse.Position.X + game.CameraOriginX ), game.CueY -( game.Mouse.Position.Y + game.CameraOriginY )))*sin( vectorToAngle(( game.Mouse.Position.X + game.CameraOriginX )- game.CueX ,( game.Mouse.Position.Y + game.CameraOriginY )- game.CueY ))
===============
game.CueY ::This is the Y position of the Cue Ball. The Reticule uses this as its origin to know where it will be and to calculate its relative position.
That big mess after it: Its the calculations needed so the reticule can be in a position that is relative to the ball using the mouse position.
min(100, ::This is the front part of the min function. min(x,y) This will make sure the reticule actor will be no more than 100px away from the position of the cue ball.
magnitude( game.CueX -( game.Mouse.Position.X + game.CameraOriginX ), game.CueY -( game.Mouse.Position.Y + game.CameraOriginY ))) ::This gives you the absolute distance between the cue ball and the reticule using the magnitude function. magnitude(x,y) is the same as the value of x^2 + y^2. Extending this function to use endpoints of a line segment will give you the length of a line segment. i.e. magnitude(x1-x2, y1-y2)
Adding the camera origin to the mouse position is needed since the value of the mouse position doesn't change relative to the device(computer, iPhone, etc).
sin( ::Since I pulled this expression from the Y position constrain for the reticule, I need to use the sine function. I would need to cosine for the X position. Multiplying the magnitude expression above with this sine function will give me the vertical component of the value. Now I need the angle for this.
vectorToAngle(( game.Mouse.Position.X + game.CameraOriginX )- game.CueX ,( game.Mouse.Position.Y + game.CameraOriginY )- game.CueY )) ::This will give you the relative angle between 2 points of a line segment. The inner equation is the same as the one used in the magnitude expression above.
I'll read through it a couple of times to let it sink in, before having a fiddle about with my project.
Ive not tried it out yet, but from the effort youve put into explaining things for me, I think I owe you some icons if you want to take me up on the offer. Drop me a private message to let me know if/when/what you require and I'll be happy to sort something out for you
thanks again!!