Mathematical problem
OrvilFox
Member Posts: 67
How to determine the position(x,y) of the green dot by the circle?
Could use all the functions provided by GS.
I need a dynamic equation for this, it will looks like (x=3.5pier-6,y=1.7*r^2) <JUST FOR EXAMPLE! NOT A REAL EQUATION!
I've been thinking about a lot of possible equations but none of them actually work.
Comments
There must be more to your question. The X/Y position of the dot is known to the dot, and can be passed easily to the circle or any other actor. Please explain in more detail what you mean
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The green dot is an actor and the circle is another actor.
Let's see if I want to attach the green dot on that position on the circle.
Now, the circle starts to rotate, which means that the green dot needs to move with the circle because they are attached. Therefore I think I need an equation showing the relationship between the rotation of the circle and where should the dot move. Then I could use "Constraint Attribute" to achieve my goal.
:* Maybe it is a little bit hard to understand, so I wish I explained it well.
@Armelline I think they are wanting to know how to find the x,y position of a point on a circle given the x,y coordinates of the center of the circle. Of course, you'd need to know the measurement of the angle to that point as well.
Starting point: http://www.mathopenref.com/coordbasiccircle.html
Edit: didn't see the above post before I answered... glad I was on the right track
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Do a search for @Socks' fast constrain demo. That can do what you seem to be asking. Unless what you're asking is closer to what @tatiang suggests.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Amazing! This is exactly what I expected, I'll give it a try and see if it works or not.
The green dot's location is:
X = radius of the circle * cos (circle's angle)
Y = radius of the circle * sin (circle's angle)
I can't believe it! You definitely made my day.
Thanks for providing the resources, now it's working like a champ!
Thanks, it worked! You are the man!
P.S what I posted only shows where the green dot is in relation to the circle, it assumes the centre of the circle is x0, y0, but if your circle is elsewhere in your scene (for example in the middle of the scene) then you'd need to add in the circle's location to the equation like this:
The green dot's X = radius of the circle * cos (circle's angle) + circle's X position
The green dot's Y = radius of the circle * sin (circle's angle) + circle's Y position
Thanks for providing the solution!
One question about your Fast Constrain v2, why does the child disappeared if I move it to the lower layer than the parent?
It probably has to do with the sequence in which things are processed by GS.
The later order of thing is very important!
GameSalad scans a project's code like this:
Lowest layer first > Lowest actor within that layer > Topmost code first within that actor.
The child actor needs information about the parent's position and rotation to calculate its own position and rotation - that information needs to be generated before the child actor calculates its position, if the child actor is below the parent actor then that cannot happen.
A simple timer should fix this issue?
Thanks for the information. And I tried to spawn a child actor at a certain position, but it did not, it seem like the actor constrained to the parent even before it spawned. Is this a GS thing too?
Sorry I don't know what that means, too vague for me
Umm, just use the "Spawn actor" to spawn a child actor, let's say at x=50 y=30.
If the parent actor didn't move, it will spawn at x=50 y=30.
But if the parent actor moved, it will spawn at somewhere else maybe x=81, y=29.
How do I spawn the child actor at x=50 y=30 despite the movement of the parent actor?
Whether the parent actor (the actor that is doing the spawning) moves or does not move will have no effect on the location of the child actor, if you set the parent actor to spawn the child at x50, y30 then that's where the child will be spawned regardless of the parent's motion.
Simply add the rule:
The parent didn't move, so the child spawned at the right position:
The parent moved, the child spawned at somewhere else:
Still need help!
I can't spawn child actors at a position.
Hmmmm . . . . let me have a think, the project wasn't really designed to do precisely what you want, and your mission-creep makes it hard to predict what is next on your list of things this project must do . . . but I expect all you need do is allow for an offset of some kind, I've not got access to the project or GS at the minute, but I'll try and work it out on paper . . . back in a minute . . .
Ok, for it to work how you want the rules for the child actor should look like this:
Change OFFSET to parent's rotation.
Change LocalX to selfX
Change LocalY to selfY
Change LocalRotation to selfRotation
Change Radius to magnitude( parentX - selfX , parentY - selfY )
Change Angle to vectorToAngle( selfX - parentX, selfY -parentY )
Constrain selfX to Radius *cos( Angle + parent's rotation - OFFSET )+ parentX
Constrain selfY to Radius *sin( Angle + parent's rotation - OFFSET )+ parentY
Constrain selfRotation to LocalRotation + parent's rotation - OFFSET
That should work, I can't remember what I called the attributes in the actual project, but you should be able to work out which is which . . . . basically all I am adding in is an offset for the child's rotation.
Awesome! Although I didn't fully figure out how it processed yet but it works perfectly!
Thanks I think that's all I need for this project.
I'll definitely credit you since those equations you provided is the core of this game
What game will this be? Let's wait and see
Good ! Didn't get to test it myself, glad it works for you.
No need to credit me. Please don't credit me.
Circular Flappy Bird ?