Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: frozze on July 12, 2014, 08:45:46 AM

Title: How can this be done?
Post by: frozze on July 12, 2014, 08:45:46 AM
Hi.

What is this about?
As shown on GM1, i have a dot in the middle and the player rotating around the dot. When clicked, the game starts and the player gets sucked into the dot. The player can however avoid this by holding down click to get away from the dot, and when not holding down click, the player is pulled towards the dot. The player is always rotating around the dot no matter the distance.

What I have tried:
I've been playing around with the circular gravity asset, but it seems to be hard to have direct control over the physicsmovement. So nonphysics seem to be the way to go?

I would like some tips on how to make the following.
1. The player should always rotate around the dot.
2. Make the dot like a blackhole, so the player gets pulled towards it.
3. I somehow need to do something so when i hold down click, the player gets away from the dot. I'm guessing addforce could do it?

On GM2 I've imagined how it could look like. The path is just to visualize the path the player takes when holding down click.

Hobe you can give some tips ;)
Title: Re: How can this be done?
Post by: 1982 on July 12, 2014, 11:22:43 AM
This is how I would do it:

1. Make a empty gameobject at the position of the dot, this is the pivot of the rotation
2. Make another empty g.o. as a child of the pivot
3. Move the this g.o. away from the pivot as much as you want the starting diameter of the rotation to be
4. Animate the pivot so that it rotates 360 degrees, now it looks like the second g.o. goes around the dot

5. Make the player object take position (Get Position, Set Position) from the second g.o. every frame, now the player rotates around the dot

6. Now use "set scale" action for the pivot, and when you change the scale value to anything less than 1, it looks like player gets closer to the dot. At scale of 0, the player will go in the middle of the dot.

7. Using "Float Subtract" action and float variable together with the "Set Scale" you can make the scale go down constantly. And when player clicks a button you can reverse the operation in a another state, so that the scale gets bigger.

(If the animation overrides the scale set, make the pivot object as a child of other gameobject at the dot, and use the scale to that g.o.)
Title: Re: How can this be done?
Post by: frozze on July 13, 2014, 09:44:40 AM
This is how I would do it:

1. Make a empty gameobject at the position of the dot, this is the pivot of the rotation
2. Make another empty g.o. as a child of the pivot
3. Move the this g.o. away from the pivot as much as you want the starting diameter of the rotation to be
4. Animate the pivot so that it rotates 360 degrees, now it looks like the second g.o. goes around the dot

5. Make the player object take position (Get Position, Set Position) from the second g.o. every frame, now the player rotates around the dot

6. Now use "set scale" action for the pivot, and when you change the scale value to anything less than 1, it looks like player gets closer to the dot. At scale of 0, the player will go in the middle of the dot.

7. Using "Float Subtract" action and float variable together with the "Set Scale" you can make the scale go down constantly. And when player clicks a button you can reverse the operation in a another state, so that the scale gets bigger.

(If the animation overrides the scale set, make the pivot object as a child of other gameobject at the dot, and use the scale to that g.o.)

Cool, thanks for your reply. I'm at point "5" atm, but stuck here. I've attached a get+set position on the player and using the second g.o as gameobject. But it doesn't work. Got any idea whats wrong?
Title: Re: How can this be done?
Post by: 1982 on July 13, 2014, 12:40:10 PM
You need to refer the player object with the "Set Position" action.

Also make a Vector3 variable and put it to both actions where it says "Vector"
Title: Re: How can this be done?
Post by: LogLady on July 13, 2014, 08:07:54 PM
I used this concept that 1982 described when I tried to replicate the Mr Flap behaviour but it works better for an Atomic+ like game. The problem I had with Mr Flap was how to use add Force and keep the rotation and position of the child of the "pivot object".
Title: Re: How can this be done?
Post by: frozze on July 14, 2014, 06:04:17 AM
You need to refer the player object with the "Set Position" action.

Also make a Vector3 variable and put it to both actions where it says "Vector"

Hi again. Might be a stupid question, but how do you refer the player object?
Title: Re: How can this be done?
Post by: frozze on July 14, 2014, 06:08:08 AM
I used this concept that 1982 described when I tried to replicate the Mr Flap behaviour but it works better for an Atomic+ like game. The problem I had with Mr Flap was how to use add Force and keep the rotation and position of the child of the "pivot object".

Hi.
Did you end up doing it right?
Title: Re: How can this be done?
Post by: LogLady on July 14, 2014, 09:56:24 AM
@frozze
Just change the "starting pos" to your player object.

I just gave up doing it. The player object had a rigidbody (to use the addForce) and I couldn't figure how to rotate it around the pivot looking to it and keep to same position without the player object "shaking" along the way...
Title: Re: How can this be done?
Post by: frozze on July 14, 2014, 02:31:35 PM
Yay got the set/get pos working now, and the player is spinning around the dot. Now I'm trying to do the set scale and float subtract. However when i press play, the player is teleportet to the middle of the pivot. I think it's the set scale that does it? How do i avoid that?
Title: Re: How can this be done?
Post by: LogLady on July 14, 2014, 04:12:28 PM
Set the float variable "pull" to 1 in the variable editor.
Title: Re: How can this be done?
Post by: frozze on July 15, 2014, 12:02:15 PM
Great thanks, got it all working now :)
Title: Re: How can this be done?
Post by: frozze on July 16, 2014, 07:33:14 AM
Btw I have one last question. Instead of clicking/tapping to add float (move out) out, how is it possible to hold down click/tap add float (move out)?
I'm using finger gestures and tried their longpress, tap and hover event without result. Anyone got an idea how to do this?
Title: Re: How can this be done?
Post by: LogLady on July 16, 2014, 08:27:52 AM
I never used the touch tools but I guess they work the same as the mouse stuff.

Use 1 touch event and set it to began on the first state, on second state use touch event ended. just change it where you are using the mouse input. I guess   ;D
Title: Re: How can this be done?
Post by: frozze on July 16, 2014, 08:56:26 AM
Problem is that it only recognize the very first click and stops after 1 sec. I somehow want it to keep moving while down.
Title: Re: How can this be done?
Post by: frozze on July 16, 2014, 12:52:21 PM
Nvm, solved it.
Title: Re: [SOLVED] How can this be done?
Post by: frozze on July 30, 2014, 09:30:05 AM
Update:

I'm trying to make a new way to control the player. You can see the picture how i immagine it to be. The sliders the the left is just to simulate the control and don't have to be there, i want it to be that the player can just click everywhere in the screen (hold mouse down and pull back to get the player away from the center) and (hold mouse down and move up to get the player close to the center).
Got any idea how to do this?