playMaker

Author Topic: Move Forward around object [SOLVED]  (Read 13142 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object
« Reply #15 on: November 11, 2013, 11:19:22 PM »
Hi,

 Very good.

 Ok, you don't set the gravity based on the trigger world position, instead you set the gravity based on the trigger orientation. Does that make sense?

Open the "level" gamObject and select one of its "Gravity Trigger" gamobject.

-- in there you have a fsm with a simple "TRIGGER ENTER" listener that broadcast in turn a "GRAVITY TRIGGER" global event.

-- the "Gravity Manager" catch this "GRAVITY TRIGGER" global event in the fsm "Gravity Manager", it gets the actual collider, and compute it's -Y direction which is the direction of the gravity for that trigger ( basically your world gravity becomes relative to this collider transform orientation, Y means up, -Y means down).

-- Then the "Gravity Manager" fire an event to the ball itself to "SET GRAVITY".

Does that clarify things?

bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object
« Reply #16 on: November 12, 2013, 05:30:15 AM »
Ok I understand that part now. Let say i wanted to rotate the player. Im just about to enter the trigger and the trigger is e.g. 90 degrees on its Y axis from the players Y axis. If i enter, can i rotate the player to match the Y axis of the Gravity Trigger?

I can do this manually by specifying the rotation but wondered if this could be dynamically?

This is my last question lol. I will put this to resolved if i can. :)

Thanks for your time!

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object
« Reply #17 on: November 12, 2013, 06:10:45 AM »
Hi,

 yes, you simply have the player look forward using the "up" vector as the Y axis of the collider he just hit.

bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object
« Reply #18 on: November 12, 2013, 06:36:23 AM »
Thanks Jean!!!!! i got it to work! woop!  :D

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object
« Reply #19 on: November 12, 2013, 09:12:11 AM »
Hey, Sorry after i implemented i realised that the player doesn't always align up? im using the same principle as the Camera Adjustment (look at ball). But just using the player to adjust self. But it tends to over rotate to far forward?

Im thinking ive done the setup wrong. Nearly achieves what i want to do.

Ive included a link from my dropbox showing screenshot of the setup i have as trying to upload one here throws back a database error? Any further guidance would be greatly appreciated!

https://www.dropbox.com/s/lln4rb3te8nxswz/player%20adjustment.jpg

Sorry to be a pain!
« Last Edit: November 12, 2013, 09:14:14 AM by coxy17 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object
« Reply #20 on: November 14, 2013, 12:10:11 AM »
Hi,

 Does it align up for a while and then stop? it could be because you simply stop looking?

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object
« Reply #21 on: November 14, 2013, 09:56:16 AM »
Hi, Yes you are right. simple mistake. Finally there!!!! thanks for all your help!!!!!

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #22 on: November 19, 2013, 08:29:17 AM »
Hi Jean,

I noticed an issue with the 'smooth look at direction 2' action. When i get the 'velocity' of the 'direction' and i apply this every frame it sometimes auto rotates the player back to the original position and not the triggers (or another random direction). Ive posted here as it relates to this post and didnt want to make another.

1. Player enters trigger
2. Player auto rotates and positions fine (always checking)
3. Sometimes the player keeps on flickering and don't find the new direction and stops in the weird position (there is no way of always replicating this, it seems like its random/buggy) it seems to occur when catching the edge of the trigger?

Ive captured the video to show you what happens. I have highlighted the trigger to show where it is before i clicked play. The first time i go back to the trigger (0:18) is when the random auto rotation occurs. the 2nd time i enter (0:26) it enters fine and remains int he same direction?

https://www.dropbox.com/s/3hysnxo97oq6het/test%20trigger.avi

Thanks

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #23 on: November 19, 2013, 09:46:40 AM »
Hi,

 gravity triggers and the ball look at are not linked at all, the ball is only checking for its own velocity, It's not a problem with the action per say, it's a problem of design.

 In your case, you might want to no use the ball velocity for the camera work but just the last trigger, just like it defines the gravity it would define the forward direction for the camera work.

 Does that make sense?

bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #24 on: November 20, 2013, 02:21:58 AM »
Hi,

i sort of understand, I have setup the 'trigger' to get its velocity and sore in a global variable. Then i used 'smooth look at direction 2' on the player and it always looks at its Z axis.

But the problem is when i enter the trigger going against the triggers Z axis and it always flips the player 180 degrees around when the player stops inside. What am i doing wrong? I think i might of not understood lol.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #25 on: November 20, 2013, 09:14:44 PM »
Hi,

 You are simply facing a problem of design. All of the tools you are using are working, it's just that it doesn't end up being something logical from a user point of view.

 in our case, I would still use the actual player velocity to compute the camera work, but actually implement a threshold so that if the player speed is lĂ©ower then a certain value the camery only follow the position, not the orientation.

 You'll likely have to resort to that kind of tricks to get all of this right.

 
bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #26 on: November 26, 2013, 02:14:46 AM »
Hi Jean,

I understand what you are referring to now. Frustrating lol. Could I use the triggers velocity and combine it with the players velocity? i mean to float the X,Y or Z and do something there? just speculating, might be talking rubbish as im still fairly new to Unity Scripting.

Ive looked into Vector3.RoateTowards, is this something that I could possibly experiment with?

The camera work is fine now, however, the player when entering a new trigger rotates but not to the triggers velocity? it seems to be keeping its own world XYZ?

thanks

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #27 on: November 28, 2013, 02:49:09 AM »
Hi,

 I think you are facing some angle issues more than anything else. The best way is to experiment for sure.

Combining velocity is not a good idea I think, what you want is a simpler approach. But using the trigger axis to define the camera angle would be the way to go, it would not rotate with the player, only follow the player position while keeping the current trigger camera orientation. So you only orient the camera once when hitting a new trigger and simply kep matching the player position ( and not its orientation)


 Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #28 on: November 28, 2013, 09:55:19 AM »
Hi,

Yes I get what your are on about, it is an angle issue. The problem is more with the player being at the wrong angle when entering first trigger. It doesnt align straight so when i use my keys to move the player forward, it wont as its XYZ isnt the same as the trigger, causing it to move incorrectly (wrond direction to the trigger XYZ).

Could i use Quaternions to achieve the rotation? possibly Lerp?

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14109
  • Official Playmaker Support
    • View Profile
Re: Move Forward around object [SOLVED]
« Reply #29 on: November 28, 2013, 10:30:41 PM »
Hi,

 The problem would stay the same, as it is by design, you need to find a new way for your camera or character behavior. the one way out of this as I think of it is to only have the camera rotating when the character speed is greater than a threshold valud, so that if the character turn in place, the camera won't move. OR you could only turn if the player is moving forward, that would work too.

Bye,

 Jean