Forum rules - please read before posting.

Timed Transform on SCALE?

edited August 2014 in Technical Q&A
Here is what i want to do based on how i understand, AC, and it is what i Need to do to please my professor,

As you've known I am making A Farm Simulation Game so that means CROPS,

here is what i want to do with crops

first, When i plant their seeds, I want it to make its own "Time left to Harvest" Variable when it reaches "0" then i can harvest it,
there are a total of 30 farm plots so far that i can plant on and 5 different Crops so far.. does that mean 30*5= 150 different variables? Can Anyone please help me for each and every detail, 
=
For example i want  my carrot Seeds to be harvested at 8 hours in game time, so i need to have a timer for each instance my carrot seed is planted, so that it will run differently and be harvested at different times, that is my main problem now
==

, help me please :( everybody on this community 

second, I want my crops prefab scale to grow by a certain number every instance that a certain number of time is deducted to the "Time left to Harvest" Variable of a certain specific crop i have planted, to make a "Growing Crop effect"

last but not the least, How can i Change or Swap my crop prefab with another fully grown crop prefab once the  "Time left to Harvest" Variable is 0 to show that its fully grown, 

that is all i ask for now thank you so very much you would save my life and my future if you answer this thank you thank you no words can express my thanks if you'll help me :)


Comments

  • Since you're making a farming simulator in an adventure game engine, I'm not surprised you're having some teething problems!  You'll need some custom scripts, but it should be possible.

    1) Yes, you will need one variable per crop.

    2/3) Attach a custom script to each crop.  This should get you going - you might have to tweak the numbers.  In the Inspector, give appropriate values each of the exposed properties (ID values are the number next to each Variable in the Variables Manager).  The current crop model (oldPrefab) should be a child object, so that it can be removed without deleting the whole thing.

    using UnityEngine;
    using System.Collections;
    using AC;

    public class CropGro : MonoBehaviour
    {

        public int inventoryID;
        public float timeToGrow;
        public GameObject newPrefab;
        public GameObject oldPrefab;

        private void Update ()
        {
            float timeLeft = GlobalVariables.GetFloatValue (inventoryID);
            float size = 1f + ((timeToGrow - timeLeft) / timeToGrow);
            transform.localScale = new Vector3 (size, size, size);

            if (timeLeft <= 0f)
            {
                Destroy (oldPrefab);
                Instantiate (newPrefab, transform.position, Quaternion.identity);
            }
        }
    }

  • Thanks Chris ! :) you're a Life Saver, might as well get started on the Variables haha theres alot of them i mean alot :/
  • mr chris? or anybody that can assist me ? may you be so kind to answer my question once again,, its related to this ,

    1. How do i spawn that crop(with the attached script) via the hotspot on my farm plot? or do i just make a Call Custom Script on the actionlist i've used on the hotspot on my plots?

    because here is how i've made my planting effect before:
    ===
    First, i've made alot of planted carrotseeds (my beta Crop) at a very far away place from my game area, when the player clicks the hotspot with the required seed, it will be teleported to the marker at the specific farm plot i have put on there,
    Then with that, after a day(in-game) has passed, it will automatically move to another far far away place then it will be replaced with a full grown carrot,

    ..but my "client/prof" wanted it to grow by scale not instantly so thats when i have come to you,, my game is 80% finished everything is working, i've set up shops via dialogues and conversations, i've set up animals, NPCs, Sleeping, and such.. all that i need is this planting logic, sorry if i am such a nag or a disturbance to you i am very stuck may you please help me :( im
  • What's wrong with the script I wrote?  I'm sure you'd need to tweak the values to get the speeds correct - don't expect to just plug it in and have it working!
  • the script you wrote is working, i've changed some values on the integer, i got it now, i got some idea just as i was writing this comment, thank you,, i cant thank you enough sir
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.