playMaker

Author Topic: Very easy, very quick Q  (Read 1717 times)

richardh

  • Junior Playmaker
  • **
  • Posts: 97
Very easy, very quick Q
« on: January 28, 2015, 06:06:58 PM »
I get my vector3 position and store it in variable 'position'. I want to add say 5 to the 'z' of 'position' and store the result in a variable 'newposition'.

This sounds easy and straight forward but I've been faffing for 30 mins and can't do it. I have used Vector3 add but the new variable (newposition) Z position keeps doubling when I use it in a spawned prefab. So Z=5 in the first spawn will be z=10 in the next, then z=20... 40..80 etc.

can someone help me?

thanks

richardh

  • Junior Playmaker
  • **
  • Posts: 97
Re: Very easy, very quick Q
« Reply #1 on: January 28, 2015, 07:18:46 PM »
UPDATE:
Think I have sussed how to setup the vector3 variables but...

Is it okay to create a clone of a clone of a clone.... ad infinitum?

I have a plane with a trigger that will create another plane and trigger in the z axis ahead so that when the player enters the trigger a new plane is created for him to walk onto. And then the next trigger does the same. Works fine but the create object is a clone of the clone, so if I kept walking for an hour I would have a clone x1000 in the hierarchy. I suspect that's not good. The clones are destroyed after 10 seconds so at any one time there will only be 4 planes/triggers in the scene but the name of the planes would be plane(clone)(clone)(clone).... ad infinitum

I have obviously set this up wrong even thought I get the result I want (a never ending path). How can I fix this?

ta

rik

  • Full Member
  • ***
  • Posts: 246
Re: Very easy, very quick Q
« Reply #2 on: January 29, 2015, 03:43:14 AM »
you need to know one thing here it was not hard to do this but before adding value for the posi you need to remember that your spawn need to wait until you have added some value to the position and activate the spawn position.

if this confused you ask me again

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Very easy, very quick Q
« Reply #3 on: January 29, 2015, 07:14:31 AM »
Vector3 Add will add a value to the same Variable while Vector3 Operator will do the math and save the result in a different variable.

It sounds like you just need Vector3 Add. Then its basically just Create Object (or Set Position, changing position of a scene Object) and using that position. The only way to really break it is to run the Add too many times or something, maybe even changing the position after it spawns? Not sure, just need to debug it and make sure no other FSMs are interfering.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D