playMaker

Author Topic: Array object to hand transform  (Read 1208 times)

Aaron2348

  • Playmaker Newbie
  • *
  • Posts: 16
Array object to hand transform
« on: October 15, 2020, 06:26:40 PM »
Hi. I'm needing some help with built in array actions in playmaker i have made a array variable and want to randomly set an object in the array to a transform in my characters hand
Every time a scene starts, As far as i have gotten is making the variable and setting the Get Random array action in a state but i don't know where to go from here, anyone who can help i would highly appreciate it
The Wolves

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Array object to hand transform
« Reply #1 on: October 16, 2020, 07:07:11 AM »
Use ArrayList It is on the Ecosystem. It is much better than the original array.

In your case,

1. Go to variable tab on your fsm. Enter a name and set its type to array.
then you click on the variable that you just made and set its content to Vector 3.
then you can add how many vector3 values u want
fill it

2. Fill the array with values, in your case vector3 value, u should make more than one value since you want to random get it.

3. Check if you've successfully retrieved the random vector3 into your variable (myVector3)

3. Then u can set transform with your myVector3
« Last Edit: October 16, 2020, 07:11:11 AM by ch1ky3n »

Aaron2348

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Array object to hand transform
« Reply #2 on: October 16, 2020, 08:25:19 AM »
Use ArrayList It is on the Ecosystem. It is much better than the original array.

In your case,

1. Go to variable tab on your fsm. Enter a name and set its type to array.
then you click on the variable that you just made and set its content to Vector 3.
then you can add how many vector3 values u want
fill it

2. Fill the array with values, in your case vector3 value, u should make more than one value since you want to random get it.

3. Check if you've successfully retrieved the random vector3 into your variable (myVector3)

3. Then u can set transform with your myVector3

Hey thanks for the reply, So i did download array list but i think its much easier to do with the default arrays they are more simple for my brain, and also about arrays, i did make an array with vector 3 but my thing is how then would i instantiate a object into these vector 3s and what would i use to check myvector3 variable?
The Wolves

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Array object to hand transform
« Reply #3 on: October 16, 2020, 10:19:42 AM »
ok, I guess the "object" is a prefab, so when you create the object, you want it to randomly appear?
is that correct?

first of all, where is the array variable resides? is it on the object prefab or is it somewhere on the scene?

the easiest scenario is the array variable is reside on the object itself, then you can do this:

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Then set position UserOwner to v3 variable
3. Done

If the object is a prefab and the array reside on the scene object, then

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Create Object, Drag the prefab onto it, set position to V3 Variable
3. Done

Hope it helps

Aaron2348

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Array object to hand transform
« Reply #4 on: October 17, 2020, 11:01:43 AM »
ok, I guess the "object" is a prefab, so when you create the object, you want it to randomly appear?
is that correct?

first of all, where is the array variable resides? is it on the object prefab or is it somewhere on the scene?

the easiest scenario is the array variable is reside on the object itself, then you can do this:

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Then set position UserOwner to v3 variable
3. Done

If the object is a prefab and the array reside on the scene object, then

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Create Object, Drag the prefab onto it, set position to V3 Variable
3. Done

Hope it helps

Ok thanks im going to try this and see how it goes, the prefabs have to be parented to a weapon handler in the scene so im pretty sire the second approach will work just fine, thanks again
The Wolves

Aaron2348

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Array object to hand transform
« Reply #5 on: October 17, 2020, 09:11:51 PM »
ok, I guess the "object" is a prefab, so when you create the object, you want it to randomly appear?
is that correct?

first of all, where is the array variable resides? is it on the object prefab or is it somewhere on the scene?

the easiest scenario is the array variable is reside on the object itself, then you can do this:

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Then set position UserOwner to v3 variable
3. Done

If the object is a prefab and the array reside on the scene object, then

1. Get random array and save it into your v3 variable (Retrieve the v3 value from array)

2. Create Object, Drag the prefab onto it, set position to V3 Variable
3. Done

Hope it helps

Hey so ive tried what u said and im pretty sure its working but how could i do this for multiple prefabs? To randomly set multiple weapons in a characters hand
The Wolves

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Array object to hand transform
« Reply #6 on: October 18, 2020, 11:56:23 AM »
Hey there,

It always goes down to how are you gonna design the logic/architecture of your game.
Given the fact that prefab is unable to refer to anything outside their own hierarchy, you must do something about it and everyone has their own way to solve this.

For example, I like to design as such, so my prefab will behave immediately the moment they got spawned (Means, all the script/instruction will reside inside the prefab itself)

other time, I prefer to spawn the prefab being natural then manipulate it during the runtime, meaning all the instruction resides on whoever spawn the prefab.

In your case, You need to decide how are you gonna design so it will accomplish your long-term goal for your project.

Cheers


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Array object to hand transform
« Reply #7 on: October 20, 2020, 11:21:08 AM »