playMaker

Author Topic: [SOLVED] Replace GameObject  (Read 4012 times)

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
[SOLVED] Replace GameObject
« on: December 08, 2014, 07:27:40 AM »
Hi

I have a simple Question.
Which action do i need to replace a game object with another object.

For example. I have a spawn Point which fires Bullets. And when the ship hits an item these Bullet should be replaced.

Does anybody have an quick an easy solution for this?
« Last Edit: December 11, 2014, 08:53:18 AM by Lane »

rik

  • Full Member
  • ***
  • Posts: 246
Re: Replace GameObject
« Reply #1 on: December 08, 2014, 12:27:01 PM »
if you need to replace bullets ? in that situation make bool action for that on bool change the bullet with some other game object i think this helps

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Replace GameObject
« Reply #2 on: December 08, 2014, 01:23:23 PM »
The bullets in the scene should be replaced, or the bullets that you are going to fire after picking up and upgrade (and firing henceforth) are replaced?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #3 on: December 08, 2014, 03:09:31 PM »
Hi

The Bullets that i am going to fire after the pickup, yeah.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Replace GameObject
« Reply #4 on: December 08, 2014, 03:15:33 PM »
Alright, you're probably using the Create Object action. You should set the object you want to create as a Variable and predefine it. Then you can just change it later with Set Game Object.

Basically, after you hit the trigger/collider on the pickup, on the pickup object have an FSM that stores the collider (what ran into it) and then use Set Fsm Game Object to change that variable to something else. You could do this a few different ways, but the idea is that you make it a variable and use Set Game Object to change the object that the Ship is going to spawn. It's always going to spawn that variable, you just need to change what the variable is.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #5 on: December 08, 2014, 03:28:06 PM »
Ok ... i will try this. Which actions is better set fsm game object or set game object. or are these the wrong actions.

I have made a int switch...if 0 use bullettype_1 if 1 use bulletType_2 and so on.
So the item works ... an the ship is now firing a placeholder ... an empty object.
And now i want to replace the placeholder with an bullet object depending on the int variable.

So which action should i use to replace on bullet with another?


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Replace GameObject
« Reply #6 on: December 08, 2014, 03:38:37 PM »
It depends on where you're changing it from, Set Fsm Game Object is for reaching from one Fsm to another, while Set Game Object would be for use inside the same Fsm.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #7 on: December 08, 2014, 04:05:38 PM »
Ok so ... I should create the bulletobjects somewhere outside  from the screen or what .... to predefine  them. ..store  them as a variable ? .... I dont really  understand the process. .. how Do I replace it. ?

Can you write how the fsm  wich Changes the object woll look like... in my case  i would  use  the create Fan object  because i Do it from another  fsm

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Replace GameObject
« Reply #8 on: December 08, 2014, 04:11:29 PM »
By predefine I mean create a GameObject variable and drag your bullet prefab over to it, I'll call it myBullets.

To change myBullets, use Set Game Object or Set Fsm Game Object (whichever is necessary in your case) and change that variable to something else.

Now when you fire simply tell it to use the myBullets variable.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #9 on: December 08, 2014, 04:15:06 PM »
Ok i think i get it. .. I will try this and tell you if it worked how  i did  it.
Thanx

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #10 on: December 09, 2014, 06:03:01 AM »
Hm...the Set FSM Game Object want a string name of a variable.
I cant figure out what this means. Could this be myBullets in this case or what?

Mornar

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Replace GameObject
« Reply #11 on: December 10, 2014, 06:15:01 PM »
Allright got it.
It has not worked because it was a global.

Thanks for helping.