playMaker

Author Topic: How can this be done?  (Read 6806 times)

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
How can this be done?
« 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 ;)
« Last Edit: July 30, 2014, 09:30:27 AM by frozze »

1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: How can this be done?
« Reply #1 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.)
« Last Edit: July 12, 2014, 11:24:50 AM by 1982 »

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #2 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?

1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: How can this be done?
« Reply #3 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"

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How can this be done?
« Reply #4 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".

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #5 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?

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #6 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?

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How can this be done?
« Reply #7 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...

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #8 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?

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How can this be done?
« Reply #9 on: July 14, 2014, 04:12:28 PM »
Set the float variable "pull" to 1 in the variable editor.
« Last Edit: July 14, 2014, 04:43:28 PM by LogLady »

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #10 on: July 15, 2014, 12:02:15 PM »
Great thanks, got it all working now :)

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #11 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?

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How can this be done?
« Reply #12 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

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #13 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.

frozze

  • Playmaker Newbie
  • *
  • Posts: 25
Re: How can this be done?
« Reply #14 on: July 16, 2014, 12:52:21 PM »
Nvm, solved it.