• Projects
  • Rabbits vs Marblez- WIP Tower Defense Game Demo for feedback

I hadnt thought of that, sounds good, but Im not sure how much it would help- you would still need to check every half minute or so which is closer.

Does the size of the models matter for speed? I am having to scale some models down to like 0.02 xyz.

Isn't there some sort of profiler that tells you what is using the most processing power in Godot? I feel like there is but I've never used it, so can't tell u where it is.

@jbskaggs said: I hadnt thought of that, sounds good, but Im not sure how much it would help- you would still need to check every half minute or so which is closer.

Perhaps have a queuing system so there's a target acquisition step on every frame but only one unit at a time? That might work to keep the average FPS up and avoid horrible frametime spikes.

@Megalomaniak said:

@jbskaggs said: I hadnt thought of that, sounds good, but Im not sure how much it would help- you would still need to check every half minute or so which is closer.

Perhaps have a queuing system so there's a target acquisition step on every frame but only one unit at a time? That might work to keep the average FPS up and avoid horrible frametime spikes.

current 1. all enemies go in an array. 2. shooters target enemies when they first appear and check all members in array for closest enemy 3. enemy removed at destruction

so the suggested steps would be:

  1. if enemies are within range. -ignoring all other enemies.
  2. put those enemies in array
  3. target closest enemy in array
  4. remove any enemies that are destroyed or leave range from the array

??

HTML5 is pretty fast. Obviously not native speed (since there are several translation layers) but it's not as slow as people think. In an optimized game you can get full VSync locked performance on a decent system. And general performance improvements to the native version will carry over, so try profiling and see what the bottlenecks are.

By the looks of it, this shouldn't have any performance problems.

One thing you could try for start is to create marbles as instances of the same scene.

@xyz said: By the looks of it, this shouldn't have any performance problems.

One thing you could try for start is to create marbles as instances of the same scene.

I do that already. Their material changes base on their health level, I added an area collision for shooters and only do the raycasting and look_at for the enemies during collision.

After these tweaks I have no lagging. Having every tower run thru every array and apply raycasting to every array member was the drag.

Why do you even need raycasting for any of this? Just use simple distance calculations.

@xyz said: Why do you even need raycasting for any of this? Just use simple distance calculations.

I was using it to calculate cursor and distances. Now I am only using it for cursor

Something's still not quite right. Judging by the eye, the framerate drops below 60 when more than a few marbles enter the view. Scene of this complexity should run perfectly smooth.

@xyz said: Something's still not quite right. Judging by the eye, the framerate drops below 60 when more than a few marbles enter the view. Scene of this complexity should run perfectly smooth.

let me update the file on itch.io.... there. I forgot to update it.

How do you check for fps on itch?

It's better now but still doesn't look like a proper 60 fps. Fps value can be obtained via: Performance.get_monitor(Performance.TIME_FPS) Just put it into a label in your gui.

@xyz said: It's better now but still doesn't look like a proper 60 fps. Fps value can be obtained via: Performance.get_monitor(Performance.TIME_FPS) Just put it into a label in your gui.

var frameRate = Engine.get_frames_per_second() This is what I used before. Is your the same or is it part of debug mode or something?

@Erich_L Should be ok either way. Some of the stuff in Performance object is available only in debug mode.

I added the fps label to bottom right corner. On my system averages 30fps and seems capped at 30fps.

I updated the file as well for yall to check.

Does Godot have a FPS cap setting Im ignorant of?

Definitely something funky happening with marbles. It starts at 60 fps and by the time all of the marbles scroll into view it falls to about 15. All this without any rabbits placed onto the map.

Same behavior in Firefox, Edge and Brave.

Hmmm here the generation script for the marbles:

extends Spatial
var counter=0
var timer = 0
var wave_level=1 #Global.wave_level
var enemy =preload("res://models/pathfollow.tscn")
var enemies_size=0
# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.

var wave
var enemy_id=0
var enemy_spacing = Global.enemy_spacing






# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	wave_level=Global.wave_level
	if wave_level==1:
		wave=['Y','Y','Y','Y','Y','R','Y','R','Y','Y','Y','Y','Y','Y','Y','Y','R','Y','R','R','R','Y','Y','Y','Y','Y','R','Y']
		#DEVELOPMENT WAVE TESTING
		#wave=['J','J','J','Y','Y','R','B','R','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y']
	if wave_level==2:
		wave=['Y','Y','Y','R','R','G','Y','G','R','R','R','R','G','G','R','R','R','R','Y','Y','Y','Y','R','R','R','R','R','R']
	if wave_level==3:
		wave=['G','Y','R','R','R','B','G','','R','R','R','R','G','G','R','R','B','B','G','G','G','G','G','G','G','R','R','R']
	if wave_level==4:
		wave=['R','R','G','G','G','B','B','B','RB','R','R','R','G','G','G','G','G','G','G','Y','G','G','G','G','G','B','B','B']
	if wave_level==5:
		wave=['R','R','G','B','B','J','B','B','R','RB','R','G','J','G','G','RB','G','Y','G','G','G','G','G','Y','G','B','B','B']
	if wave_level==6:
		wave=['B','RB','G','B','B','J','J','B','R','RB','R','G','G','G','G','J','G','B','G','G','G','G','G','J','G','B','R','Y']

	if Global.start_wave==true:
		timer += 1 * delta
		if timer>=enemy_spacing:

			if enemy_id<wave.size():
			
		#yellow marbles
				if wave[enemy_id]=="Y":
					Global.enemy_my_name="color_marble"
					Global.enemy_health=1      #sets life of marble- marble color determined by life size
					print("wave level: " + str(Global.wave_level))
					var newEnemy=enemy.instance()
					add_child(newEnemy)
					newEnemy.add_to_group("enemies")
			
			#red marbles
				if wave[enemy_id]=="R":
					Global.enemy_my_name="color_marble"
					Global.enemy_health=3     #sets life of marble- marble color determined by life size
					var newEnemy=enemy.instance()
					add_child(newEnemy)
					newEnemy.add_to_group("enemies")
			
				#yellow marbles
				if wave[enemy_id]=="G":
					Global.enemy_my_name="color_marble"
					Global.enemy_health=5      #sets life of marble- marble color determined by life size
					var newEnemy=enemy.instance()
					add_child(newEnemy)
					newEnemy.add_to_group("enemies")
			
				#yellow marbles
				if wave[enemy_id]=="B":
					Global.enemy_my_name="color_marble"
					Global.enemy_health=9      #sets life of marble- marble color determined by life size
					var newEnemy=enemy.instance()
					add_child(newEnemy)
					newEnemy.add_to_group("enemies")
			
			
				enemy_id+=1
				timer=0
	#checking if wave is clear if so does end of wave stuff gold, popup, etc	

			if enemy_id>1 and wave.size()>1:
				var enemies = get_tree().get_nodes_in_group("enemies")
				if enemies.size()==0:
					Global.wave_level+=1
					if Global.wave_level==7:
						get_node("../Node2D/Game_Over_Popup").show()
					else:
						get_node("../Node2D/Wave_Complete_Popup").show()
#					
					if Global.wave_level<=6:
						Global.map_gold+=200
					
#					
					Global.start_wave=false
					get_tree().paused = true
					var bullets = get_tree().get_nodes_in_group("bullets")
					for bullet in bullets:
						bullet.queue_free()
					wave=[]
					enemy_id=0

and here the script for tmoving marble down path on pathfollow

    func _process(delta):
	offset+= 2*delta

ANd here the script for the marble

extends Spatial


var mylife=Global.enemy_health
var myname=Global.enemy_my_name
var blue_material=preload("res://models/color_1650274_005.material")
var green_material=preload("res://materials/green_spatialmaterial.tres")
var red_material=preload("res://models/color_15277357_001.material")
var yellow_material=preload("res://materials/new_spatialmaterial.tres")

# Called when the node enters the scene tree for the first time.

#func _ready():


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
		if myname=="color_marble": #and myname!="robot_marble":
			if mylife==9:
				$CSGSphere.set_material(blue_material)
			if mylife==5:
				$CSGSphere.set_material(green_material)
			if mylife==3:
				$CSGSphere.set_material(red_material)
			if mylife==1:
				$CSGSphere.set_material(yellow_material)
				


#	pass


#	pass # Replace with function body.

func _on_Enemy_Area_area_entered(area):
	area.get_name()

	#check if touching goal
	if area.name=='EndGoal':
		print(Global.player_lives)
		Global.player_lives-=1
		get_parent().get_parent().queue_free()
		queue_free()
	#collision with bullet		
	if area.name=='bullet':
		Global.current_gold+=5
		mylife-=1		
#		area.queue_free()
		if mylife<=0:
			get_parent().get_parent().queue_free()

if in the script for the marble I eliminate all the preloads and material changes FPS stays at 60. But if I leave them in it drops down to 6 fps.