Questions in topic: "increase"http://answers.unity.com/questions/topics/single/3138.html
The latest questions for the topic "increase"Mathf.lerp to increase intensity and range of pointlighthttp://answers.unity.com/questions/1652217/mathflerp-to-increase-intensity-and-range-of-point.html
Hello hello dear people it's Anna!
I am working on a piece where I have point lights with rigid bodies flying around. When they collide with certain game Objects they change color and make a sound. This already works perfectly. But now I want them to increase range and intensity over time and then go back to normal (maybe during 2 sec). For some reason it doesn't seem to be working.
This is the code at the moment:
public float minimumIntensity = 7f;
public float maximumIntensity = 100f;
public float minimumRange = 1f;
public float maximumRange = 10f;
//starting value for lerp
//Make slider
[SerializeField]
[Range(0f, 1f)]
public float t = 0.0f;
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Musicplant" || collisionInfo.collider.tag == "Plant")
{
currentColor = colorList[random.Next(0, colorList.Count - 1)];
pointLight.intensity = Mathf.Lerp(minimumIntensity, maximumIntensity, t);
pointLight.range = Mathf.Lerp(minimumRange, maximumRange, t);
//increase the t interpolater
t += 0.2f * Time.deltaTime;
Once this works, I would add this second part to decrease it again:
// now check if the interpolator has reached 1.0
// and swap maximum and minimum so game object moves
// in the opposite direction.
if (t > 1.0f)
{
float temp = maximumIntensity;
maximumIntensity = minimumIntensity;
minimumIntensity = maximumIntensity;
minimumIntensity = temp;
float tempp = maximumRange;
maximumRange = minimumRange;
minimumRange = maximumRange;
minimumRange = tempp;
t = 0.0f;
}
}
}
I think the problem lies with time.deltaTime since pointLight.intensity += 20f works
but pointLight.intensity += 20f * time.deltaTime doesn't do anything at all.
Anybody has an idea or a solution? Thanks for reading!lightingtimetime.deltatimeincreasemathf.lerpSat, 27 Jul 2019 17:09:34 GMTOBIC_MuseReward system logic code problemhttp://answers.unity.com/questions/1642163/reward-system-logic-code-problem.html
what wrong with my code? does anybody know? I want to make star system, if player fail the fail canvas is pop up, and star will give 2 stars as player fail 1 times and so one..
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MiniLvlStar : MonoBehaviour
{
public GameObject fail1x1, fail1x2, fail1x3;
var timesclick:float = 0.0;
//attach to wincanvas
// Start is called before the first frame update
void Start()
{
failtimes = PlayerPrefs.GetInt ("failtimes");
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) && EventSystem.current.currentSelectedGameObject != fail1x1)
{
timesclick ++;
Debug.Log("Fail 1x1");
}
if (Input.GetMouseButtonDown(0) && EventSystem.current.currentSelectedGameObject != fail1x2)
{
timesclick ++;
Debug.Log("Fail 1x2");
}
if (Input.GetMouseButtonDown(0) && EventSystem.current.currentSelectedGameObject != fail1x3)
{
timesclick ++;
Debug.Log("Fail 1x3");
}
}
if (timesclick = 0){
timefail == 0;
PlayerPrefs.SetInt("failtimes, 0");
//show 3 stars
star3.gameObject.SetActive(true);
star2.gameObject.SetActive(false);
star1.gameObject.SetActive(false);
}
if (timesclick = 1){
timefail == 1;
PlayerPrefs.SetInt("failtimes, 1");
//show 2 star
star3.gameObject.SetActive(false);
star2.gameObject.SetActive(true);
star1.gameObject.SetActive(false);
}
if (timesclick = 2){
timefail == 2;
PlayerPrefs.SetInt("failtimes, 2");
//show 2 star
star3.gameObject.SetActive(false);
star2.gameObject.SetActive(true);
star1.gameObject.SetActive(false);
}
if (timesclick >= 2){
timefail == 3;
PlayerPrefs.SetInt("failtimes, 3");
//show 1 star
star3.gameObject.SetActive(false);
star2.gameObject.SetActive(false);
star1.gameObject.SetActive(true);
}
}
}logicincreasestarsFri, 21 Jun 2019 09:34:32 GMTstaryzhelioshow to give a reward when level completed??http://answers.unity.com/questions/1636839/how-to-add-point.html
int pointadd = 20;
public Text txtpointadd;
public void GetClaim() //when user click getclaim then add a 20 point when complete
{
txtpointadd.text = txtpointadd.text + pointadd;
}
I currently work on 15 levels in my game, and would like to make a increase the reward by 20% by every level. player will be given his reward when the level finished.
how to reward stored in next level??pointincreaseSat, 01 Jun 2019 09:09:41 GMTrahulpatil6220375How do I make a controllable horde increase in population?http://answers.unity.com/questions/1595639/how-do-i-make-a-controllable-horde-increase-in-pop.html
I am working on a 2d top-down game where you control a zombie horde and take over the medieval region. I have a script that allows the player to grow in size a bit like agar.io but, I need it to instead create a new sprite that is controlled by the player every time a person is infected by a zombie.playersizeincreaseamountTue, 29 Jan 2019 11:28:45 GMTGhostOfTheJokerhow to increase or decrease ammo ?? but depending of ammo in inventoryhttp://answers.unity.com/questions/1580569/how-to-increase-or-decrease-ammo.html
so i want to make ammo script but i confused when increase or decrease ammo,
int currentAmmo; //i already make maksimum is 40 and minimum is 0
int ammoInventory; //and i make maksimum is 500 and minimum is 0
//so i want to add currentAmmo, but depending of ammoInventory
if (reloading)
{
if (currentAmmo <= 0 && ammoInventory > 40)
{
//i make simple increase and decrease
currentAmmo = 40;
ammoOnInventory -= 40;
//how can i make if currenAmmo = 15 and ammoInventory = 10
//currentAmmo should only be added 10
}
}
thanksc#increasedecreasedependentThu, 13 Dec 2018 01:41:19 GMTWhisperXDHow to gradually increase a float ShaderGraph inspector variable from -1 to 1 through codehttp://answers.unity.com/questions/1574919/how-to-gradually-increase-a-float-shadergraph-insp.html
Hey guys, for a school project I have to create a game in a team of 5, I'm the game developer and i'm a beginner in Unity.. I do have a little knowledge in coding tho...
currently, I have a dissolve shader using shader graph ( brackeys tutorial ) but I'm trying to dissolve the objects into the screen on keydown (space) and make them disappear using the dissolve shader on a second keydown (space).
currently what happens is when I press space the object shows itself and on the second keydown it disappears again.. i did some googling and came up with the current code but the shader itself isn't transitioning/animating..
(I did also find something about lerp but for some reason, I can't figure that out)
I hope that someone knows how to do this, thank you guys in advance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mechanicSwitch : MonoBehaviour {
public Material dissolveMat;
public bool build;
// animate the game object from -1 to +1 and back
private float shown = -1f;
private float hidden = 1f;
// Use this for initialization
void Start () {
dissolveMat.SetFloat("_DissolveReference", hidden);
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Space))
{
if (build == false)
{
dissolveMat.SetFloat("_DissolveReference", hidden);
build = true;
}
else
{
dissolveMat.SetFloat("_DissolveReference", shown);
build = false;
}
}
}
}
![alt text][1]
![alt text][2]
[1]: /storage/temp/128328-unity.jpg
[2]: /storage/temp/128329-dissolveshader.jpgshaderinspectorlerpincreasegraduallySun, 25 Nov 2018 23:14:19 GMTSpoocheyHow to increase Value of for example "gold" every second?http://answers.unity.com/questions/1534931/how-to-increase-value-of-for-example-gold-every-se.html
Hello, thank you for taking time for my question!
I want to create a small game that has a small simple economy. Every second, for example, the value ' Gold ', which is represented as text, has to be increased by 1 every second.
I imagine this:
At the top left corner is ' Gold: 15 '
After that, the value ' 15 ' should be counted up every second.
Would anyone have a C# script for me please?valuecountincreasesecondsFri, 27 Jul 2018 16:41:34 GMTRichymanHow to make a torus that grows only in diameter?http://answers.unity.com/questions/1517422/how-to-make-a-torus-that-grows-only-in-diameter.html
Hello, everyone. I am making a game where I use a torus to represent an orbital path of a spaceship. I want to make the torus grow in diameter, but not thickness. I'm saying that the walls of the torus should stay the same size, but the diameter grows, similar to how a balloon inflates, its inside area grows, yet the balloon doesn't get any thicker. I can't even begin to think how I'd pull this off. If this isn't possible, how else would I pull off an orbital trajectory line? (e.i. like something out of Kerbal Space Program) Thanks for your help!sizeorbitincreasespaceflightTue, 12 Jun 2018 17:55:23 GMTTheEmeraldRubyHow to increase two floats for every frame the space button is pushed down?http://answers.unity.com/questions/1517068/how-to-increase-two-floats-for-every-frame-the-spa-2.html
Hello, everyone. The title pretty much explains it all. How would I increase two floats by a value of my choice every frame the space button is pushed down? Thanks for your help!intframeincreaseMon, 11 Jun 2018 19:58:36 GMTTheEmeraldRubyHow can i randomly increase/decrease a value over time?http://answers.unity.com/questions/1498811/how-can-i-randomly-increasedecrease-a-value-over-t.html
Basically I want to make something like a stock market in my game.c#valueincreasemoneydecreaseWed, 25 Apr 2018 23:27:21 GMTkebupapa_unityHow to create a step by step array to inrease y position? 3Dhttp://answers.unity.com/questions/1489841/how-to-create-a-step-by-step-array-to-inrease-y-po.html
Hallo,
i need help to increase a field of generated objekts step by step on the y axis. I want to start at 0 with the first row and increase the value row by row.
My script:
void Start () {
GenerateLevel ();
//trying to increase position
tempPos = transform.position;
transform.position = tempPos;
transform.position = new Vector3(transform.position.y, 5.0f, transform.position.z);
}
//generating objects
void GenerateLevel ()
{
for (int x = 0; x < map.width; x++)
{
for (int z = 0; z < map.height; z ++)
{
GenerateTile (x, z);
}
}
}`
![alt text][1]
[1]: /storage/temp/114290-problem.png
Hope you can help me outarraypositionincreaseThu, 05 Apr 2018 08:55:32 GMTCaptCommunismhow to make a healthbar increasehttp://answers.unity.com/questions/1483918/how-to-make-a-healthbar-increase.html
I'm trying to add to an existing script a way to increase health by 10 points, the health pickup is destroyed so thats no problem. Im getting a CS0019 error can anyone help?
public PlayerHealth playerHealth;
public Slider healthSlider;
public float HealthUp = 10;
//PlayerHealth.currenntHealth playerHealth.currentHealth;
void OnTriggerEnter (Collider col)
{
if (col.gameObject.tag == "Player")
{
Destroy(gameObject);
Debug.Log ("pickup working");
}
}
private void Update ()
{
if (playerHealth < 100)
playerHealth = playerHealth + HealthUp;
}healthhealthbaraddincreaseplayer damageThu, 22 Mar 2018 18:16:00 GMTNosmohow make the coin not increased when the player touch them more than one?http://answers.unity.com/questions/1464076/how-make-the-coin-not-increased-when-the-player-to.html
hallo master..
i need some help i have a script ( score script) and i want to make the coin when the player touch the coin more than one, the coin can't increase my score. i need only a touch to increase the score. more than that the value does not increase.
how can i setup my script??? please
public int scoreTogive = 100;
private ScoreManager theScoreManager;
// Use this for initialization
void Start () {
theScoreManager = FindObjectOfType<ScoreManager> ();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D (Collider2D bojo)
{
if (bojo.gameObject.name == "Player")
{
theScoreManager.AddScore(scoreTogive);
}
}
}collisioncollidertriggerscoreincreaseSun, 04 Feb 2018 15:30:26 GMTrhendragradual ambient light intensity changehttp://answers.unity.com/questions/1436359/gradual-ambient-light-intensity-change.html
I am in a dark tunnel so no light except low ambient. As I come out of the tunnel I want to increase the intensity - I have an empty gameobject at the end of the tunnel and when the player gets within a certain distance I get the brightness to increase but how do I do this over time? Or rather, as the player gets closer the brightness increases and further the brightness decreases. The code below just acts light a light switch rather than gradual
using UnityEngine;
using System.Collections;
public class ambientIncrease : MonoBehaviour {
public float liteChange = 5f;
public Transform Player;
void Start () {
}
void Update () {
if (Vector3.Distance (transform.position, Player.position) <= liteChange) {
RenderSettings.ambientLight = new Color(.5f, .5f, .5f, 255);
}
}
}floatincreaseambient lightTue, 28 Nov 2017 17:37:06 GMTshadowpuppetIncreasing value by one every second, if right arrow is pressed - C#http://answers.unity.com/questions/1389411/increasing-value-by-one-every-second-if-right-arro.html
Hello, I have a float "Levelint" and I want to increase it by one while I am holding the right arrow. So, when I hold the right arrow it will increase by one, every second, and if I just press the right arrow, to just add one, once.
Does anyone know how to do this? Any help would be appreciated, thanks!
If the question doesn't make sense, let me know and I can try to explain it better.c#buttonkeyincreaseholdFri, 04 Aug 2017 19:30:39 GMTRatimidIncreasing score based on speedhttp://answers.unity.com/questions/1363828/increasing-score-based-on-speed.html
I am having trouble increasing score based on speed of the car with a few lines of code. I know how to do it with score vs time with
yield return new WaitForSeconds(x);
, and I know how to this with 5 or 6 conditions and 20 lines of code ,but I wanted to do this with a few lines of code. It's possible ?.
What I want is:
Score + = 1 point every 1 second if car speed = 1
Score + = 1 point every 0.8 seconds if car speed = 3
Score + = 1 point every 0.6 seconds if car speed = 6
Score + = 1 point every 0.4 seconds if car speed = 9
Score + = 1 point every 0.2 seconds if car speed> 9
I m using two Coroutines, one for score and another for speed, activated on Start function:
private IEnumerator ChangeSpeed()
{
while (true){
yield return new WaitForSeconds(1);
if(speed < 2.0f || speed < 9.0f && gameStart){
speed += 3.0f;
}
if(speeding)
velocity = speed + 1f;
else
velocity = speed;
}
}
private IEnumerator ChangeScore()
{
while (true){
yield return new WaitForSeconds(1);
if(gameStart){
scoreNum += 1;
scoreText.text = scoreNum.ToString();
}
}
}speedscorescore systemincreaseincrementSat, 10 Jun 2017 13:06:51 GMTPedroPatIncrease speed from 0f-10f over timehttp://answers.unity.com/questions/1342068/increase-speed-from-0f-10f-over-time.html
Hey Guys :)
Maybe you can help me :)
I want to increase the speed of an object from 0.0f to 10.0f over 1 minute (variable maybe i do 30 sec at least) without pressing anything so the speed increases when the game starts. I read so much solutions in this forum but nothing worked for me... or do that what i wanted. You can see my latest code down low. I really hope u can support me with ur experience ;)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
float currentSpeed = 0f;
float maxSpeed = 10f;
public float movementSpeed = 5.0f;
public GameObject player;
private float screenCenterX;
private void Start()
{
// save the horizontal center of the screen
screenCenterX = Screen.width * 0.5f;
}
private void Update()
{
//////////////// Not really worked /////////////////////////////////////////////////////////////////////////////
currentSpeed = Mathf.Lerp(currentSpeed, maxSpeed, Time.deltaTime);
transform.position -= transform.forward * currentSpeed * Time.deltaTime;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// if there are any touches currently
if (Input.touchCount > 0)
{
// get the first one
Touch firstTouch = Input.GetTouch(0);
// if it began this frame
if (firstTouch.phase == TouchPhase.Began)
{
if (firstTouch.position.x > screenCenterX)
{
// if the touch position is to the right of center
// move right
StartCoroutine(RotateAround(Vector3.up, 90.0f, 0.35f));
}
else if (firstTouch.position.x < screenCenterX)
{
// if the touch position is to the left of center
// move left
StartCoroutine(RotateAround(Vector3.up, -90.0f, 0.35f));
}
}
}
else
{
transform.position -= transform.forward * Time.deltaTime * movementSpeed;
}
}
IEnumerator RotateAround(Vector3 axis, float angle, float duration)
{
float elapsed = 0.0f;
float rotated = 0.0f;
while (elapsed < duration)
{
float step = angle / duration * Time.deltaTime;
transform.RotateAround(transform.position, axis, step);
elapsed += Time.deltaTime;
rotated += step;
yield return null;
}
transform.RotateAround(transform.position, axis, angle - rotated);
}
}playergamespeedturningincreaseTue, 18 Apr 2017 09:21:07 GMTLathursplayers chance of winning is increased based on their level.http://answers.unity.com/questions/1318138/players-chance-of-winning-is-increased-based-on-th.html
Hi guys, I have a very challenging problem I would love some help with! I code in C#
The Players Names are stored in List Player. The Player level is List Chances. If Amy is level 7 and George is level 9, Cindy is level 4, Dave is level 2, Emily is level 5, Frank is 17.
The Game randomly shows a winner based of the new chances a player has to win, Frank should win.
Here is my example code:
using System.Collections.Generic;
using UnityEngine;
public class WhoWonGame: MonoBehaviour
{
private string winner;
List<string> Player;
List<int> Chances;
List<string> PlayerChances;
public void Start()
{
for (int j = 0; j < Player.Capacity; j++)
{
// PlayerChances = Player + Chances;
}
}
public void whoWon()
{
// winner = Random.PlayerChances;
Debug.Log(winner);
}
}
I would love the help! This might not be possible... How do I store the data to make it work? The data is collected from the client and sent to the server when a player clicks a UI button.playerlevelincreasepercentagechanceSun, 26 Feb 2017 13:21:47 GMTkevin5141Decreasing a value over time, called by InvokeRepeatinghttp://answers.unity.com/questions/1312856/decreasing-a-value-over-time-called-by-invokerepea.html
I'm attempting to create an effect in my game in which two discreet spot lights lower and raise their intensity every so often to give the impression that the player is actually travelling through space.
The method I'm using does work to an extent;
void Start ()
{
InvokeRepeating("LightChange", 5, 30);
}
void LightChange()
{
if (Random.value >= 0.5f)
{
dirLight1.intensity -= (Mathf.Clamp(0.05f * Time.deltaTime, 0.00f, 0.5f));
dirLight2.intensity += (Mathf.Clamp(0.05f * Time.deltaTime, 0.00f, 0.5f));
}
else
{
dirLight1.intensity += (Mathf.Clamp(0.05f * Time.deltaTime, 0.00f, 0.5f));
dirLight2.intensity -= (Mathf.Clamp(0.05f * Time.deltaTime, 0.00f, 0.5f));
}
}
It works in that the function is called and the value for the light intensity does indeed change, although it only changes for a moment (from .5 to .45) whereas the intended effect is that the values would decrease/increase to their minimum/maximum respectively.lightingfloatinvokerepeatingincreasedecreaseTue, 14 Feb 2017 03:18:41 GMTKyleF1997Increasing or decreasing int values quickly?http://answers.unity.com/questions/1287129/increasing-or-decreasing-int-values-quickly.html
I'm making an RTS game where resources are gathered and taken away, when gaining or spending resources I would like to increase or decrease them quickly instead of taking them or adding them all at one shot. The resources are int values since I don't want decimals in my resources. Is there an easy way to do this? Thanks!!resourcesintrtsincreasedecreaseSat, 17 Dec 2016 22:36:41 GMTDJGhostViperIncrease Performance of precomputation processhttp://answers.unity.com/questions/1266652/increase-performance-of-precomputation-process.html
I sincerely never dedicated time to learn what exactly is this: I think it's called precomputation process, correct me if i am wrong, but i didn't found this in the docs or anything.
![alt text][1]
So i am literally going to call it "this thing" for now. By the way, PLEASE don't vote down my question because you think it's funny. Anyway, depending on the scenes of my projects sometimes i get THOUSANDS of jobs per step, and it takes a long time to do those things. I would like to know if there is a way to make this process go faster.
I changed from 3 VERY different performance gpus and my pc still take the same amount of time when baking lights, clustering, transporting lights, etc...
[1]: /storage/temp/81495-thisthing.pngperformanceincreaseFri, 04 Nov 2016 01:34:42 GMTZitooxIncrease speed in float over time.http://answers.unity.com/questions/1255894/increase-speed-in-float-over-time.html
Newbie here :)
Im trying to increase speed in float over time.
public float Speed = 6.0f;
void Update()
{
if (Speed <= 16.0f)
{
Speed += Time.deltaTime / 6f;
}
}
Then I run the game, the object dont increase in speed, however the Inspector changes in the value Speed.
Can anyone please point me in the right direction :)
ThanksspeedincreaseThu, 13 Oct 2016 19:08:48 GMTMiltonN00BHow to increase +1 when countdown reachs to 0?http://answers.unity.com/questions/1253120/how-to-increase-1-when-countdown-reachs-to-0.html
Hi everyone... Hm.. so, I would like to know how do I increase +1 when a countdown reachs 0, and after that, the countdown start again. Now the countdown is set to 60.0f. I also would like to know how do I set it in the scene view. I have a canvas, and in that I have a Text where is attached the countdown script, and another Text which is where I want to being increasing the value one by one, like it is 1, after goes 2, 3, 4 and so on, and as I said I want the countdown to restart every time it reaches 0 and the value of the other text increass by 1.
Oh, and I am working with c#.
Well, that's all, thanks.c#countdownincreaseincrementFri, 07 Oct 2016 12:21:29 GMTVictorSIlvaKHow can I change the value of a Float smoothly?http://answers.unity.com/questions/1239849/how-can-i-change-the-value-of-a-float-smoothly.html
Its might be kinda a silly, but I can't seem to get it to work. What I want is for my float to go to its new value over time, check:
var Speed : float = 0;
function Called(){
Speed = 100;
//I would like this to happen smoothly, however, I would also like to change back to say 40 if I call it later.
yield WaitForSeconds(2);
Speed = 40;
// So the first time its changed from 0 tot 100, and the second time from 100, 40, how can I make this smooooothhh?
}
Thanks!lerpfloatintincreasespeed issuesTue, 06 Sep 2016 13:30:51 GMTPaulsnijderHelp with making a endles runnerhttp://answers.unity.com/questions/1229491/help-with-making-a-endles-runner.html
Hi! I am a script beginner, and i am trying to make something that makes my vehicle go forward automatically. I was making an endless runner game, and i made the script (with help) but i deleted it and stopped the project. But now i want to finish it again xD
The problem is that i don't have the script anymore :V
can someone help me? Everything i know is that i need to make a variable or a public float and then make something that changes the speed of the vehicle, and then, finally, i need to make it go automatically, and start to speed up as time goes. Can someone help me?scripting beginnerspeedmovement scriptendless runnerincreaseSun, 14 Aug 2016 23:56:34 GMTZitooxIncrease difficulty Space Shooterhttp://answers.unity.com/questions/1226062/increase-difficulty-space-shooter.html
I'd like to increase the difficulty of the Space Shooter from the Unity learn section by increasing the speed of the hazards after every wave, but the wavespawn is controlled by the GameController script, while the speed of the asteroid is controlled by anoter script, how do I access and change the speed variable from the other script? (I'm using C#).c#variablesspace shooterincreasescritpingSun, 07 Aug 2016 13:23:00 GMTkevin9889nivekAdd variable from another script?http://answers.unity.com/questions/1219544/add-variable-from-another-script.html
I created these two scripts:
1)
public var goTransform:Transform;
var sp:float = 0.5f;
var Incrementscript : Increment;
function Awake()
{
goTransform = this.GetComponent(Transform);
}
function Update()
{
goTransform.position.z = goTransform.position.z - sp;
}
function OnTriggerEnter(other : Collider)
{
if (GetComponent.<Collider>().tag == "Inc")
{
sp = sp + Incrementscript.incr;
}
}
2)
#pragma strict
var incrementTime = .1;
var incrementBy = 0.05;
static var incr = 0.5;
function Awake () {
InvokeRepeating("Incrementvar", incrementTime, incrementTime);
}
function Incrementvar () {
incr += incrementBy;
}
every x seconds is spawned a prefab that contains the first script.
The second script is contained in a gameobject trigger.
the sp variable contained in the prefab(script 1), passing through the trigger, should add up to the incremented number in this second script, increasing the speed (sp) of the prefab. in this way each prefab will have a different speed, more and more high. The number increases but is added to sp, what I did wrong?javascripttriggervariableincreaseFri, 22 Jul 2016 15:36:39 GMTDigitalWolfHow to increase an integer by 1 every 2 of another integerhttp://answers.unity.com/questions/1213098/how-to-increase-an-integer-by-1-every-2-of-another.html
Hey guys!
First time posting here! I am currently making a RPG that is somewhat similar to Runescape but 2D. I am currently stuck on how to increase the player's max hit (by 1) every 2 strength levels. The combat system is going to be using Random.Range(0, maxHit).
maxHit is going to be affected by the strength but I have no idea how to actually make the 'maxHit' variable increase for every 2 strength levels. Currently starting at 1 strength, the player can hit anywhere from 0 to a max hit of 2.
I would love some help to point me in the right direction or an explanation on how to do this!c#integerincreaseFri, 08 Jul 2016 11:32:56 GMTPur3Increasing Enemy Speedhttp://answers.unity.com/questions/1208649/increasing-enemy-speed.html
I have enemy script that includes the speed. I can get the original script to work, but I wanted to add some difficulty to my game. I tried to increase the speed based on the user's score, but now the enemy does not move at all. I have tried several different things and cannot get the enemy to move. The enemy spawns, but just stands still. What am I doing wrong or what could I add to fix this issue?
Here's my code:
Working Code:
using UnityEngine;
using System.Collections;
public class RightGloves : MonoBehaviour {
public GameObject glove;
//public Vector3 target;
public static float increaseSpeed=0;
private float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
speed = Random.Range (6, 10);
float change = (speed+=increaseSpeed ) * Time.deltaTime;
glove.transform.Translate(Vector3.left *change );
Destroy (gameObject,4);
}
}
Non - Working Code:
using UnityEngine;
using System.Collections;
public class LeftGloves : MonoBehaviour {
public GameObject glove;
//public Vector3 target;
public static float increaseSpeed=0;
private float speed;
private int level=0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (ScoreManager.scoreCount >= 10000 && ScoreManager.scoreCount < 20000 && level ==0) {
level++;
speed = (Random.Range (6, 10)) * Time.deltaTime;
//float change = (speed+=increaseSpeed ) * Time.deltaTime;
glove.transform.Translate(Vector3.right * speed);
Destroy (gameObject,4);
}
if (ScoreManager.scoreCount >= 20000 && ScoreManager.scoreCount < 50000 && level ==1) {
level++;
speed = (Random.Range (8, 12)) * Time.deltaTime;
//float change = (speed+=increaseSpeed ) * Time.deltaTime;
glove.transform.Translate(Vector3.right *speed);
Destroy (gameObject,4);
}
if (ScoreManager.scoreCount > 50000 && level ==2) {
level++;
speed = (Random.Range (10, 14)) * Time.deltaTime;
//float change = (speed+=increaseSpeed ) * Time.deltaTime;
glove.transform.Translate(Vector3.right *speed);
Destroy (gameObject,4);
}
}
}enemyspeedscoreincreaseMon, 27 Jun 2016 04:34:37 GMTEl-DeiabloHow to smoothly increase the speed of rotationhttp://answers.unity.com/questions/1177571/how-to-smoothly-increase-the-speed-of-rotation.html
Hello Devs!
I want my object to increase rotation speed smoothly from 0 speed to 5 on the z axis, so if someone knows the solution i would be very grateful if you could share it with me!
Here is my code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class rotateleft : MonoBehaviour, IEventSystemHandler {
public float speed = 2f;
bool buttonHeld = false;
public void pressed (BaseEventData eventData)
{
buttonHeld = true;
GameObject.Find("LeftImage").GetComponent<Animation>().Play("LEFT");
}
public void notpressed(BaseEventData eventData)
{
buttonHeld = false;
GameObject.Find("LeftImage").GetComponent<Animation>().Play("LEFT1");
}
public void FixedUpdate()
{
if (buttonHeld)
{
transform.Rotate(Time.smoothDeltaTime, 0, speed * Time.deltaTime);
}
}
}rotaterotate objectz-axisincreaseWed, 27 Apr 2016 15:19:59 GMTBondolero