#Hastebin: Send and Save Text or Code Sni...

1 messages · Page 1 of 1 (latest)

gilded ridge
#

Making it a thread so it doesn't get buried

pure glen
#

sure!

#

also if you want i can provide a screen recording tho id need to lelearn how to use obs lmao

gilded ridge
#

im lookin over teh first script u sent that inherits from Powerup, do u have that script too?

pure glen
#

yea one second

gilded ridge
pure glen
#
using System.Collections.Generic;
using UnityEngine;

public class powerupscript : MonoBehaviour
{
    public Powerup powerup;
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Destroy(gameObject);
        powerup.Apply(collision.gameObject.GetComponent<BirdScript>());
    }

}
#

thats the whole powerupscript

pure glen
gilded ridge
#

You could try using a fixed spawn rate by using Time.fixedDeltaTime instead of Time.deltaTime when updating the timer variable. This would ensure that the pipes are spawned at a consistent rate regardless of the frame rate of the game.```
#

maybe its framerate? maybe ur frames drop when u pickup the powerup and ur pipe instantiates before or after it technically should... i don't see anything that stands out tbh

#

ya i think thats the problem

#

when u scale using time.delta time ur technically multiplying

pure glen
gilded ridge
#

in ur case ur adding.. soo.. if ur game runs faster, the timer will have more added onto it

#

than if ur running a lower frame rate

pure glen
# pure glen

as you can see the first offset pipe after the powerup is not always in the same place, sometimes spawing practically on top of the last powerup pipe

gilded ridge
#

try substituting fixedDeltaTime instead

#

it may not spawn exactly wher eu want them to, but u can adjust that by multiplying a multiplier to adjust it

#

but what u wanna be looking for is if that change causes them to spawn more consistently

pure glen
#

it doesnt seem to fix it, it only made the powerup pipes spawn further away from each other at the very end of a powerup

gilded ridge
#

🤔 hmm thats all i got for now

#

ill tell ya wat tho, when i get more free time i'll try to pull them scripts into my own project set it up with cubes or something and see if i can work out whats going on

#

don't have the time to do it right now, but i'll remember, and give u a ping if i turn up anything, until then keep trying to get some answers i guess.. someone more code savvy than me might turn up and have the solution in their back pocket

pure glen
#

thats how it looks now if thats useful

#

the first pipe after powerup still spawns inconsitantly

gilded ridge
pure glen
#

oh yea that very first pipe is supposed to be like that

gilded ridge
#

summed up in one screenshot, this is immediately after picking up the powerup, and the pipes nearest to the player spawned in on top of the ones that wer already there

#

ohh yea?

#

ohh no i see

#

the pipe nearest the player was already there

#

the 2nd set of pipes spawned in on top o fit

pure glen
#

yea i basically made the powerup bubble appear right above the bird so he immidiently picks him up, that first pipe is the pipe from spawn pipe method in the start

gilded ridge
#

cool cool, that clears it up some more, hopefully theres enuff info here to get some help w/ it

pure glen
#

so ye thats not an issue

#

i sure hope so, ill experiment more with this time.deltatime i suppose in the meantime

gilded ridge
#

use debugs

#

Debug.Log() ur time variable when u instantiate a new pipe, and then debug.log it again after ur code resets it with the new time

#

in the console that should give u an idea of why ur pipes are spawning the way they do

pure glen
lament mauve
#

know I get it

#

when using the powerup you are not using the "spawn offsets"

#

I thougth that "first born is horizontal" was literally -90 degrees

#

try to giving a value

#

a starting one

#

when you use the power up the bird doesnt have grav

#

and when calculating position from the bird pos

#

you doesnt have any variation

#

but if you has a starting value for the offset

#

and then random - or +

#

it should be fine

#

protected float hight = 2.75f;

void spawner()
{
float lowest = transform.position.y - hight;
float highest = transform.position.y + hight;

    if (timer < spawn_rate)
    {
        timer += Time.deltaTime;
    }else {
        // Instantiate (prefab, with vector 3(same X, rangom Y between lowest and highest, 0 Z), same rotation as prefab);
        Instantiate(pipes, new Vector3(transform.position.x, Random.Range(lowest, highest),0), transform.rotation);
        timer = 0;
    }
    
}

void first_spawn()
{
    Instantiate(pipes,transform.position, transform.rotation);
}
#

first declare the offset (my var is hight)

#

hope that helps

pure glen
lament mauve
#

okey pal

#

nope

#

the first spawn is just to have an initial group of pipes

#

the scene starts with empty obj that spawns pipes

#

the first spawn is without variant of height, all after it have variations

#

the function spawner configure it with spawn rate

#

I followed the same tutorial lol

#

but changed stuff

pure glen
#

sorry im back i had to do something

pure glen
#

that was intended, theyre not supposed to have any height offset

#

only this pipe is very problematic, will that fix it?

lament mauve
#

that happens bc u are boosting the pipe speed so it reaches the previous one i think

#

right?

lament mauve
# pure glen

Im was confuse about your problem until you sent that pic

pure glen
#

and i have no idea why

lament mauve
#

they have the same spawn rate

#

but diff speed

#

when you turn on the speed boost, the non boosted keeps the same but the new reach the non boosted one

pure glen
#

pipes from speedbuff (the non offset ones) have different both speed and spawn rate

pure glen
lament mauve
#

I didnt get at all what do you mean about random places

pure glen
pure glen
#

the pipe i highlighted sometimes would appear further on the right

#

or on top of the previous pipe

pure glen
#

it doesnt really seem like anyone knows how to solve it lmao

pure glen
#

ive tried using pretty much all variants of deltatime and it did affect the spawning but not the way id want it to

pure glen
#

actually i got a suggestion that i should change timer based pipe spawning to distance based on

gilded ridge
#

sure, do u know how to make a unity package?

#

if u could send me the main parts of the code, doesn't need graphics or anything, i could maybe see a better fix

#

and also, what tutorial u were following

pure glen
#

game makers toolkit absolute begginer tutorial

#

tho at this point its heavely modified

pure glen
#

do you mind if i send it in your dms?