playMaker

Author Topic: Jump at a set distance  (Read 8549 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Jump at a set distance
« on: March 07, 2014, 09:49:57 AM »
Hi,

Ive made a my player jump using the 'add force' to the object. But i cant get a precise enough jump for what im trying to achieve.

Im trying to get my player to jump from one platform to another but land exactly in the middle of the other platform (or near enough)

Does iTween offer a jump motion like in my diagram attached(arc shaped)? Or is there another way that doesn't involve iTween?

Thanks

Nick
« Last Edit: March 12, 2014, 07:40:55 PM by coxy17 »

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #1 on: March 13, 2014, 05:20:08 AM »
Im not sure whats the best solution. Ive looked into this post from @jeanfabre
http://hutonggames.com/playmakerforum/index.php?topic=1951.0 but its not quite what im after?

Ive looked over the samples but it mainly covers the 'Character Motor'. Im using 'Add Froce'

I can get near the exact target with just using 'AddForce' e.g. X=130 Y=200, but need it to adjust itself to the exact position before moving again.

Could using 'get' and 'set' position work?

Thanks

nick

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #2 on: March 13, 2014, 09:03:19 AM »
Try use a action traslate.
So, when you player jump with add force send event to another state with traslate.position

Note.: check this link and example. https://hutonggames.fogbugz.com/default.asp?W890

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #3 on: March 14, 2014, 04:23:26 AM »
Hi xhidnoda,

I have taken a look at the example and im not sure as to where to find the example within the project file you are referring to?

is it the one under the 'Jump Game' and under the player object FSM?

Thanks

Nick

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #4 on: March 14, 2014, 08:23:25 AM »
Just follow the instruction below.
When you have the example in your project, open scene of jump game.

Send image if what your don't understand.

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #5 on: March 14, 2014, 11:08:59 AM »
Hi xhidnoda,

I have attached a screenshot of my game along with the screenshot of the example game link you sent.

I cant get my head around what to setup from your suggestion....
'So, when you player jump with add force send event to another state with traslate.position'

at the moment the player jumps and lands e.g. from 0.00 > 1.98 (approx) on Z axis

How do i use 'translate.position' to finish moving the character once the player is done? so the '1.98 is 2.00'

e.g. i always need the player to jump forward and land 2.00 along Z (local) axis.

Sorry if i doesn't make sense. Could you please provide me with an example? would be most appreciated

Nick

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #6 on: March 14, 2014, 07:35:31 PM »
Hi im just replying again bit i stumbled upon an example online which use Parabola. Seems like the principle im after in playmaker, but wanted to avoid scripts.
http://forum.unity3d.com/threads/211681-Generating-Dynamic-Parabola


xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #7 on: March 14, 2014, 10:54:22 PM »
Hi
Let me see...
I'm think you don't use a add force Z axis to move your player. (Have you know the coordinates of 3D?).
In the example the player use add force to jump in the Y axis...right? So, use Y axis to jump.
Add a new action to Jump state. The action "Traslate" and set the X axis to "how far to go the player when jump in the X axis".

1. Jump with add force in Y axis (add force - action)
2. Traslate the player when don't grounded yet in X axis. (traslate - action)

Bye
Xhidnoda - from Paraguay (sorry my bad english)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #8 on: March 15, 2014, 09:57:04 AM »
Hi,

The co-ordinates are from self position 0.00 and to 2.00

The reason i cant use world position is that the character is controlled that way.

Right, i understand what you are saying in your 2 steps. But how do i use '(add force - action)'?

..............................................................................

I found this script which looked ok (but doesnt jump smoothly). Can this be made with playmaker?
Code: [Select]
using UnityEngine;
using System.Collections;

public class jump : MonoBehaviour {
public float forward, up;
public float maxForward = 10, maxUp = 10, speedForward = .01f, speedUp = .01f;
public bool jumpBool;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

if (Input.GetKeyUp(KeyCode.Space))
{
jumpBool = true;

}
if (jumpBool)
{
if (forward <= maxForward)
forward+=speedForward;
if (up <= maxUp)
up +=speedUp;

transform.position = new Vector3 (transform.position.x + forward, transform.position.y + up, 0);
}

}
}

Sorry for all the questions.

Nick

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #9 on: March 15, 2014, 10:05:04 AM »
your game is a 3D camera or 2D camera?

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #10 on: March 18, 2014, 09:23:43 AM »
3D camera.... im making a 3d game but its just a jump moving along one axis (z)

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #11 on: March 18, 2014, 03:20:06 PM »
So?...you can make this work?

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #12 on: March 18, 2014, 04:10:02 PM »
Still working on it. Haven't had time to test. Ill try it tonight.

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Jump at a set distance
« Reply #13 on: March 18, 2014, 06:46:31 PM »
I works ok  :)

Just struggling to get all the script recreated in playmaker, the code below is what im struggling over.

Code: [Select]
transform.position = new Vector3 (transform.position.x + forward, transform.position.y + up, 0);

Any ideas?

Nick

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Jump at a set distance
« Reply #14 on: March 18, 2014, 09:38:04 PM »
Make 2 variables (forward and up as Float)
Set the forward value = 5 (just example)
Set the up value = 7 (just example)


Use translate action

Set the x axis to forward variable
Set the y axis to up variable

Test.