Constrain X Y of Actor1 to Actor2 ..fails
TheGabfather
Member Posts: 633
It's my first time trying my hand at a platformer game and I thought I'd make use of a separate Actor for a Weapon. I'm used to creating puzzle games with GS so I'm feeling totally alien right now
Just doing some experiments and I've come across a weird behavior where I've Constrained the X and Y coordinates of the Weapon to that of the Character Actor, but at a certain consistent point in the scene the Weapon "flies" ahead of the Character (It goes right back to the Character when I move back).
Using Display Text to print each Actor's X coordinate shows that they should be at the same point -- but they aren't.
I've only implemented a couple behaviors so far:
-Basic Collisions
-Moving using Motion.LinearVelocity
-Jumping using Motion.LinearVelocity
-Crouching
-And the X and Y Constraints
Disabling the Jump and Crouch does not remedy the situation, so it has to either be the Rules for Moving / Constraining?
The Rules for those are simple enough -- followed tshirtbooth's tutorial on Moving to the letter, and did self.position.x/y to scene.Background.Hero.position.x/y for Constraining.
Any help/insights would be awesome! Feel free to make me feel stupid if I did a stupid mistake anywhere! I don't mind the education
Just doing some experiments and I've come across a weird behavior where I've Constrained the X and Y coordinates of the Weapon to that of the Character Actor, but at a certain consistent point in the scene the Weapon "flies" ahead of the Character (It goes right back to the Character when I move back).
Using Display Text to print each Actor's X coordinate shows that they should be at the same point -- but they aren't.
I've only implemented a couple behaviors so far:
-Basic Collisions
-Moving using Motion.LinearVelocity
-Jumping using Motion.LinearVelocity
-Crouching
-And the X and Y Constraints
Disabling the Jump and Crouch does not remedy the situation, so it has to either be the Rules for Moving / Constraining?
The Rules for those are simple enough -- followed tshirtbooth's tutorial on Moving to the letter, and did self.position.x/y to scene.Background.Hero.position.x/y for Constraining.
Any help/insights would be awesome! Feel free to make me feel stupid if I did a stupid mistake anywhere! I don't mind the education
Comments
I'm just overly curious about what happened there -- where they were displaying the same X Coordinate even though the one that was on the non-scrollable layer was obviously in a greater position? Bizarre.
Hopefully this will help though:
If you made your scene 10000x10000, it means that in scrollable layers, actors would be able to have positions between 0 and 10000 in either x or y axis. (Ignore that you can actually go outside of that area a little before the actor gets destroyed)
Your legacy iPhone screen only has 480x320 in coordinates that you can access for the mouse and touch attributes.
When the camera is all the way at the bottom left, the origin of the camera is 0,0.
If it is all the way to the top-right of this scene, the origin is (10000-480,10000-320)=
(9520,9680).
If you wanted to spawn an actor when you touch the middle of the screen, but when the camera is at the top right, you need to add the camera origin to the mouse position. So in this case, the spawn point would be (9520+480/2,9680+320/2) = (9760,9840)
You'll need to have an unlocked instance to get to that camera.Origin.X/Y value, but that should probably fix the offset issue.