playMaker

Author Topic: Performing an Action  (Read 314 times)

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 20
    • View Profile
Performing an Action
« on: May 31, 2019, 02:38:31 AM »
Hello,

I am trying to perform an action which i am not being able to achieve , so would need some help regarding it please.

I Would try to explain the problem as much as possible

I want to Spawn Object and After spawning the object it would move to a certain position.

Button : Click to create Object
So after creating obj :
So,on the other hand I put an fsm on Created Obj Prefab : Then when its created it Move Towards 0,0,0


Until this point it works ok.

So the thing o want to achieve is, When obj is created, it always moves to 0,0,0

But i want a bit of offset kind of thing , so that one object doesn't collide or show up on between each other.
Like kind of stack together in a uniform or row kind of thing

So i am not being able to do this. Any suggestion help would be great.

Regards,
Shihan


krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 990
    • View Profile
    • Fat Pug Studio
Re: Performing an Action
« Reply #1 on: May 31, 2019, 02:57:48 AM »
I don't understand what you want to do. Do you have a video example?

Thore

  • Sr. Member
  • ****
  • Posts: 332
    • View Profile
Re: Performing an Action
« Reply #2 on: May 31, 2019, 03:14:50 AM »
If you want an offset to the target location, you need to look at that variable, probably a vector3 and modify it. The principle is the same for other types.

1) Make a target location variable (I assume vector3)
2) Add a Random Float action to calculate a random offset, store in a variable.
3) Add a Vector3 Add XYZ action, and use the vector and the random floats.
4) Use resulting vector3 as target location.

If you want to randomise several axis, just use multiple Random Float for each axis, and then add them to the vector3.

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 20
    • View Profile
Re: Performing an Action
« Reply #3 on: June 02, 2019, 02:04:24 AM »
Dear Thore, Sir,

Thank you for the reply,

But its hard for me to explain ,
Like i want to Spawn Object in a Kind of Grid Pattern.

i have attached an pic to show the kind of action i want , but actually not sure how to perform the action.


apageeltd

  • Playmaker Newbie
  • *
  • Posts: 20
    • View Profile
Re: Performing an Action
« Reply #4 on: June 02, 2019, 02:06:48 AM »
I don't understand what you want to do. Do you have a video example?


Dear Sir, Thank u for the reply, Sir if u want a video example i can give u . PLease let me know

apageeltd

  • Playmaker Newbie
  • *
  • Posts: 20
    • View Profile
Re: Performing an Action
« Reply #5 on: June 02, 2019, 02:39:31 AM »
I don't understand what you want to do. Do you have a video example?


Sir Video Recording , When Player is Created and then Move To Spawn Location.
But As in the video You can see, As Player have Box Collider and Rigid Body,
Every Time New Player Created and told to move to spawn position, Bodies Collide with each other they r being pushed.

Which i do not want , i want player to move to position and then align , But o dont know how to perform that action

Video Share Link : https://drive.google.com/open?id=1xTasYf8hpMLtOiT3skJpWAFdkemFmiw7

Thore

  • Sr. Member
  • ****
  • Posts: 332
    • View Profile
Re: Performing an Action
« Reply #6 on: June 02, 2019, 04:36:15 AM »
There is probably no single action to do this. You have to make this step-by-step.

Let’s take it step-by-step.

You want to make each guy spawn and go to another location. Therefore, after each spawn, the target vector must change.

One way: make game objects, give them a gizmo, and set up the formation you want. Then get each object’s location one after another to use them as waypoints. You can put them into an array, and loop through them.

Another, more versatile way is to create the pattern mathematically with simple arithmetic. For example, after each spawn, add X+1 to an offset variable. Then add the offset to the target location vector, and each time repeat. Now you should see them aligh in a single row. If you want several rows, you need to check the offset each time and use a float compare: if offset is larger than some number (let’s call it threshold), reset it to zero, add Z+1 and continue as before, with X+1 until the second row is complete and so on. Make the threshold a variable and you can adjust how wide or deep the formation is. Also make the +1 a variable and you can control how close they are placed.